Search in sources :

Example 11 with ChainedOptionsBuilder

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());
    }
}
Also used : Runner(org.openjdk.jmh.runner.Runner) ChainedOptionsBuilder(org.openjdk.jmh.runner.options.ChainedOptionsBuilder) ArrayList(java.util.ArrayList) ChainedOptionsBuilder(org.openjdk.jmh.runner.options.ChainedOptionsBuilder) OptionsBuilder(org.openjdk.jmh.runner.options.OptionsBuilder) RunResult(org.openjdk.jmh.results.RunResult) BenchmarkParams(org.openjdk.jmh.infra.BenchmarkParams)

Example 12 with ChainedOptionsBuilder

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();
    }
}
Also used : Runner(org.openjdk.jmh.runner.Runner) ChainedOptionsBuilder(org.openjdk.jmh.runner.options.ChainedOptionsBuilder) RunnerException(org.openjdk.jmh.runner.RunnerException)

Example 13 with ChainedOptionsBuilder

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();
}
Also used : Runner(org.openjdk.jmh.runner.Runner) ChainedOptionsBuilder(org.openjdk.jmh.runner.options.ChainedOptionsBuilder) OptionsBuilder(org.openjdk.jmh.runner.options.OptionsBuilder) ChainedOptionsBuilder(org.openjdk.jmh.runner.options.ChainedOptionsBuilder) BenchmarkFinder(jenkins.benchmark.jmh.BenchmarkFinder) Test(org.junit.Test)

Example 14 with ChainedOptionsBuilder

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)));
}
Also used : Runner(org.openjdk.jmh.runner.Runner) ChainedOptionsBuilder(org.openjdk.jmh.runner.options.ChainedOptionsBuilder) OptionsBuilder(org.openjdk.jmh.runner.options.OptionsBuilder) ChainedOptionsBuilder(org.openjdk.jmh.runner.options.ChainedOptionsBuilder) BenchmarkFinder(jenkins.benchmark.jmh.BenchmarkFinder) Test(org.junit.Test)

Aggregations

ChainedOptionsBuilder (org.openjdk.jmh.runner.options.ChainedOptionsBuilder)14 OptionsBuilder (org.openjdk.jmh.runner.options.OptionsBuilder)13 Runner (org.openjdk.jmh.runner.Runner)9 File (java.io.File)3 RunnerException (org.openjdk.jmh.runner.RunnerException)3 ArrayList (java.util.ArrayList)2 BenchmarkFinder (jenkins.benchmark.jmh.BenchmarkFinder)2 Test (org.junit.Test)2 Options (org.openjdk.jmh.runner.options.Options)2 GraknSystemProperty (ai.grakn.GraknSystemProperty)1 BenchmarkParams (org.openjdk.jmh.infra.BenchmarkParams)1 GCProfiler (org.openjdk.jmh.profile.GCProfiler)1 StackProfiler (org.openjdk.jmh.profile.StackProfiler)1 RunResult (org.openjdk.jmh.results.RunResult)1