Benchmarking options
In the previous section, you learned how to run a benchmark test. In this section, we will look at the following configurable options for running our benchmarks:
- Modes
- Time units
Modes
The output of our benchmark results, from the previous section, included a Mode column that had the value of thrpt which is short for throughput. This is the default mode and there are an additional four modes. All JMH benchmark modes are listed and described as follows:
Mode | Description |
All | Measures all other modes inclusively. |
Average | This mode measures the average time for a single benchmark to run. |
Sample Time | This mode measures the benchmark execution time and includes min and max times. |
Single Shot Time | With this mode, there is no JVM warm up and the test is to determine how long a single benchmark method takes to run. |
Throughput | This is the default mode and measures the number of operations per second the benchmark could be run. |
Â
To dictate which benchmark mode to use, you will modify your @Benchmark...