NiccoMlt
NiccoMlt

Reputation: 305

Max and min time benchmark in Java with JMH

I want to write a benchmark to keep track of maximum, minimum and average time required for the execution of some Java code.

I read about JMH (Java Microbenchmark Harness) and it seems to match my needs, but I'm not quite sure about which mode should I use:

What mode can provide me min and max times? Are there any more modes, or are there other frameworks to do the job?

Upvotes: 2

Views: 951

Answers (1)

Eugene
Eugene

Reputation: 120848

If you run your @Benchmark with @BenchmarkMode(Mode.AverageTime), as a bonus, you will get an output like:

Result "StopAllBenchmarks.measureRight":
 2.387 ±(99.9%) 0.307 ns/op [Average]
 (min, avg, max) = (2.339, 2.387, 2.526), stdev = 0.080
 CI (99.9%): [2.079, 2.694] (assumes normal distribution)

Notice the min, avg, max

Upvotes: 3

Related Questions