Java Microbenchmark Harness (JMH)

The JMH is an open source project that helps you to implement microbenchmarking correctly. You can be sure that this toolkit is one of the best because it's developed by the same people who work on the JVM. 

The recommended way to work with JMH is by using Maven. You can install Maven using the instructions at the following link: Then, you can execute the following command to generate a test project:

mvn archetype:generate \
          -DinteractiveMode=false \
          -DarchetypeGroupId=org.openjdk.jmh \
          -DarchetypeArtifactId=jmh-java-benchmark-archetype \
          -DgroupId=org.sample \
          -DartifactId=test \

The generated project will have the following structure:

And the MyBenchmark ...

Get Mastering High Performance with Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.