JHM is a micro-benchmarking tool, included as part of the openjdk project.
- Home page
- JMH Samples: The best place to read, understand and learn what is happening.
- Tutorials
- Online result visualizer (jzillmann/jmh-visualizer) Very pretty UI for visualizing jmh reports.
Option | Explanation |
---|---|
-bm <mode> |
Benchmark mode (default: Throughput ):
|
-tu <TU> |
Time units (default: s ): m , s , ms , us , ns |
The easiest way to run a JMH benchmark is to create an uber-jar with the JMH driver included.
mvn package
# Using the uber jar from the command line
alias byexample_go_jmh="java -jar $(find ~+ -name jmh-by-example-*.jar)"
# Get help on the tool.
byexample_go_jmh --h
# Sanity check on the hash benchmarks
# benchmark mode: single shot
# time unit: nanoseconds
byexample_go_jmh -bm ss -tu ns HashBenchmark.hash
# Run the whole benchmark in three processes, with 4 warmups and 5 iterations
byexample_go_jmh -f 3 -wi 4 -i 5 -bm Throughput,AverageTime -tu ns
# Test one of the benchmark methods and generate a json report
# This creates a jmh-result.json file that you can drop in the online visualiser.
byexample_go_jmh -f 1 -wi 0 -i 1 -tu ns MaxPrecisionBenchmark -rf json