JMH benchmark parameters
There are many benchmark parameters that allow for fine-tuning the measurements for the particular needs of the task at hand. We are going to present only the major ones.
Mode
The first set of parameters defines the performance aspect (mode) the particular benchmark has to measure:
Mode.AverageTime
: Measures the average execution timeMode.Throughput
: Measures the throughput by calling the benchmark method in an iterationMode.SampleTime
: Samples the execution time, instead of averaging it; allows us to infer the distributions, percentiles, and so onMode.SingleShotTime
: Measures the single method invocation time; allows for the testing of a cold startup without calling the benchmark method continuously
These parameters can be specified in the annotation @BenchmarkMode
, for example:
@BenchmarkMode(Mode.AverageTime)
It is possible to combine several modes:
@BenchmarkMode({Mode.Throughput...