public class JUnitBenchmarkProvider extends Object
This class exists to configure JUB programmatically and avoid the annoying behavior of the system-property-configured XMLConsumer.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_EFFORT_FILE |
static int |
DEFAULT_ROUNDS |
static String |
ENV_DEFAULT_ROUNDS |
static String |
ENV_EFFORT_FILE |
static String |
ENV_EFFORT_GENERATE |
static String |
ENV_TARGET_RUNTIME_MS |
static String |
ENV_WARMUP_ROUNDS |
static long |
TARGET_RUNTIME_MS |
static int |
WARMUP_ROUNDS |
| Constructor and Description |
|---|
JUnitBenchmarkProvider() |
| Modifier and Type | Method and Description |
|---|---|
static org.junit.rules.TestRule |
get()
Get a JUnitBenchmarks rule configured for Titan performance testing.
|
static org.junit.rules.TestRule |
get(com.carrotsearch.junitbenchmarks.IResultsConsumer... additionalConsumers)
Like
get(), except extra JUB Results consumers can be attached
to the returned rule. |
public static final String ENV_EFFORT_GENERATE
public static final String ENV_EFFORT_FILE
public static final String ENV_DEFAULT_ROUNDS
public static final String ENV_WARMUP_ROUNDS
public static final String ENV_TARGET_RUNTIME_MS
public static final String DEFAULT_EFFORT_FILE
public static final long TARGET_RUNTIME_MS
public static final int DEFAULT_ROUNDS
public static final int WARMUP_ROUNDS
public static org.junit.rules.TestRule get()
The returned rule will write results to an XML file named jub.(abs(current nanotime)).xml and to the console.
This method concentrates our JUB configuration in a single code block and gives us programmatic flexibility that exceeds the limited flexibility of configuring JUB through its hardcoded global system properties. It also converts the IOException that XMLConsumer's constructor can throw into a RuntimeException. In test classes, this conversion is the difference between:
@Rule
public TestRule benchmark; // Can't initialize here b/c of IOException
...
public TestClassConstructor() throws IOException {
benchmark = new BenchmarkRule(new XMLConsumer(...));
}
// or, if there are extant subclass constructors we want to leave alone...
public TestClassConstructor() {
try {
benchmark = new BenchmarkRule(new XMLConsumer(...));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
versus, with this method,
@Rule public TestRule benchmark = JUnitBenchmarkProvider.get(); // done
public static org.junit.rules.TestRule get(com.carrotsearch.junitbenchmarks.IResultsConsumer... additionalConsumers)
get(), except extra JUB Results consumers can be attached
to the returned rule.additionalConsumers - extra JUB results consumers to apply in the returned rule
objectCopyright © 2012–2016. All rights reserved.