![JAR search and dependency download from the Maven repository](/logo.png)
com.fillumina.performance.producer.suite.ParametrizedPerformanceSuite Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of performance-tools Show documentation
Show all versions of performance-tools Show documentation
Configurable tool to easily compare performances of different code
snippets and to take performance telemetry of a running application.
The newest version!
package com.fillumina.performance.producer.suite;
import com.fillumina.performance.producer.PerformanceExecutorInstrumenter;
import com.fillumina.performance.producer.timer.InitializingRunnable;
import com.fillumina.performance.producer.LoopPerformances;
import com.fillumina.performance.producer.LoopPerformancesHolder;
/**
* Instrumenter that allows to execute a parametrized test.
* If a test has been already added to the
* {@link com.fillumina.performance.producer.timer.PerformanceTimer}
* it will be executed alongside the parametrized
* one defined by this class.
* Applying this class to the right instrumenter allows to execute the tests
* in a single-threaded or multi-threaded environment
* (see {@link com.fillumina.performance.PerformanceTimerFactory}).
*
* @author Francesco Illuminati
*/
public class ParametrizedPerformanceSuite
extends AbstractParametrizedInstrumenterSuite
, T>
implements PerformanceExecutorInstrumenter, ParametrizedExecutor {
private static final long serialVersionUID = 1L;
private ParametrizedRunnable actualTest;
@Override
@SuppressWarnings("unchecked")
protected Runnable wrap(final Object parameter) {
return new InnerRunnable((T)parameter);
}
/**
* Executes the given test against the previously added parameters.
*
* @return the same performance given to the consumer.
*/
@Override
public LoopPerformancesHolder executeTest(
final ParametrizedRunnable extends T> test) {
return executeTest(null, test);
}
@Override
public LoopPerformancesHolder ignoreTest(
final ParametrizedRunnable extends T> test) {
return LoopPerformancesHolder.empty();
}
/**
* Executes the given named test against the previously added parameters.
*
* @return the same performance given to the consumer.
*/
@SuppressWarnings("unchecked")
@Override
public LoopPerformancesHolder executeTest(final String name,
final ParametrizedRunnable extends T> test) {
addTestsToPerformanceExecutor();
this.actualTest = (ParametrizedRunnable) test;
final LoopPerformances loopPerformances =
getPerformanceExecutor().execute().getLoopPerformances();
consume(name, loopPerformances);
addTestLoopPerformances(name, loopPerformances);
return new LoopPerformancesHolder(name, loopPerformances);
}
@Override
public LoopPerformancesHolder ignoreTest(final String name,
final ParametrizedRunnable extends T> test) {
return LoopPerformancesHolder.empty();
}
private class InnerRunnable implements InitializingRunnable {
private final T t;
private InnerRunnable(final T t) {
this.t = t;
}
@Override
public void setUp() {
actualTest.setUp(t);
}
@Override
public void run() {
actualTest.call(t);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy