use of org.openjdk.jmh.runner.options.ChainedOptionsBuilder in project ignite by apache.
the class JmhWaitStategyBenchmark method main.
/**
* Benchmark runner
*/
public static void main(String[] args) throws RunnerException {
List<String> policies = Arrays.asList("inc", "dec", "r25", "r50", "r75");
int[] threads = { 2, 4, 8, 16, 32 };
List<RunResult> results = new ArrayList<>();
for (String policy : policies) {
for (int thread : threads) {
ChainedOptionsBuilder builder = new OptionsBuilder().jvmArgs().timeUnit(TimeUnit.MILLISECONDS).measurementIterations(10).measurementTime(TimeValue.seconds(20)).warmupIterations(5).warmupTime(TimeValue.seconds(10)).jvmArgs("-Dbench.exp.policy=" + policy).forks(1).threads(thread).mode(Mode.Throughput).include(JmhWaitStategyBenchmark.class.getSimpleName());
results.addAll(new Runner(builder.build()).run());
}
}
for (RunResult result : results) {
BenchmarkParams params = result.getParams();
Collection<String> args1 = params.getJvmArgs();
for (String s : args1) {
System.out.print(s.substring(s.length() - 3, s.length()));
System.out.print(" x ");
}
System.out.print(params.getThreads());
System.out.print("\t\t");
System.out.println(result.getPrimaryResult().toString());
}
}
use of org.openjdk.jmh.runner.options.ChainedOptionsBuilder in project mule by mulesoft.
the class AbstractBenchmarkAssertionTestCase method runAndAssertBenchmark.
/**
* Run a JMH benchmark and assert that the primary result is less than or equal to an expected value.
*
* @param clazz the JMS benchmark class.
* @param testName the name of the test method.
* @param threads the number of threads to run benchmark with.
* @param params parameters along with array of parameters values to be applied to the benchmark.
* @param timeUnit the time unit of the expected result value.
* @param assertions assertion consumer.
*/
protected void runAndAssertBenchmark(Class clazz, String testName, int threads, Map<String, String[]> params, TimeUnit timeUnit, boolean profileGC, Consumer<RunResult> assertions) {
try {
if (getBoolean(getProperty(ENABLE_PERFORMANCE_TESTS_SYSTEM_PROPERTY))) {
ChainedOptionsBuilder optionsBuilder = createCommonOptionsBuilder(clazz, testName, params, timeUnit, profileGC);
optionsBuilder = optionsBuilder.forks(1).threads(threads).warmupIterations(10).measurementIterations(10);
assertions.accept(new Runner(optionsBuilder.build()).runSingle());
} else {
ChainedOptionsBuilder optionsBuilder = createCommonOptionsBuilder(clazz, testName, params, timeUnit, profileGC);
optionsBuilder = optionsBuilder.forks(0).warmupIterations(0).measurementIterations(1);
new Runner(optionsBuilder.build()).runSingle();
}
} catch (RunnerException e) {
fail(e.getMessage());
e.printStackTrace();
}
}
use of org.openjdk.jmh.runner.options.ChainedOptionsBuilder in project configuration-as-code-plugin by jenkinsci.
the class BenchmarkRunner method runJmhBenchmarks.
@Test
public void runJmhBenchmarks() throws Exception {
ChainedOptionsBuilder options = new OptionsBuilder().mode(Mode.AverageTime).warmupIterations(2).timeUnit(TimeUnit.MICROSECONDS).threads(2).forks(2).shouldFailOnError(true).shouldDoGC(true).resultFormat(ResultFormatType.JSON).result("jmh-report.json");
BenchmarkFinder bf = new BenchmarkFinder(getClass());
bf.findBenchmarks(options);
new Runner(options.build()).run();
}
use of org.openjdk.jmh.runner.options.ChainedOptionsBuilder in project configuration-as-code-plugin by jenkinsci.
the class CascJmhBenchmarkStateTest method testJmhBenchmarks.
@Test
public void testJmhBenchmarks() throws Exception {
// number of iterations is kept to a minimum just to verify that the benchmarks work without spending extra
// time during builds.
ChainedOptionsBuilder optionsBuilder = new OptionsBuilder().forks(1).warmupIterations(0).measurementBatchSize(1).measurementIterations(1).shouldFailOnError(true).result(reportPath).timeUnit(TimeUnit.MICROSECONDS).resultFormat(ResultFormatType.JSON);
new BenchmarkFinder(getClass()).findBenchmarks(optionsBuilder);
new Runner(optionsBuilder.build()).run();
assertTrue(Files.exists(Paths.get(reportPath)));
}
Aggregations