Skip to content

Latest commit

 

History

History

jmh-by-example

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

JMH by example

JHM is a micro-benchmarking tool, included as part of the openjdk project.

Resources

JMH Options (byexample_go_jmh -h)

Option Explanation
-bm <mode> Benchmark mode (default: Throughput):
  • Throughput/thrpt
  • AverageTime/avgt
  • SampleTime/sample
  • SingleShotTime/ss
  • All/all.
-tu <TU> Time units (default: s): m, s, ms, us, ns

Running the benchmark

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