Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control number of operation per iteration JMH

My current setup:

    public void launchBenchmark() throws Exception {
    Options opt = new OptionsBuilder()
            .include(this.getClass().getName())
            .mode(Mode.Throughput) //Calculate number of operations in a time unit.
            .mode(Mode.AverageTime) //Calculate an average running time per operation
            .timeUnit(TimeUnit.MILLISECONDS)
            .warmupIterations(1)
            .measurementIterations(30)
            .threads(Runtime.getRuntime().availableProcessors())
            .forks(1)
            .shouldFailOnError(true)
            .shouldDoGC(true)
            .build();

    new Runner(opt).run();
}

How can I know/control (if possible) the number of operations is performed per benchmark ?

And is it important to set warmUp time and measurementIteration time?

Thank you.

like image 326
Xitrum Avatar asked Oct 17 '16 08:10

Xitrum


1 Answers

You cannot control the number of operations per iteration. The whole point of JMH is to correctly measure that number.

You can configure the warmup using the annotation:

@Warmup(iterations = 10, time = 500, timeUnit = MILLISECONDS)

And the measurement by:

@Measurement(iterations = 200, time = 200, timeUnit = MILLISECONDS)

Just set the appropriate values for your use case

like image 142
Svetlin Zarev Avatar answered Sep 28 '22 11:09

Svetlin Zarev