The JMH Kata is a simple project setup with some basic micro-benchmarks that you can use as a model to try out your own Java micro-benchmarks.
The JMH Kata leverages the Java Micro-benchmark Harness tool from OpenJDK.
There are two micro-benchmarks currently checked in:
IntListJMHBenchmark
This test compares the performance of filtering, summing and transforming a million randomly generated integers stored in anArrayList<Integer>
, aFastList<Integer>
and anIntArrayList
.PersonJMHBenchmark
This test compares the performance of various algorithms applied to aList
of classPerson
which has randomly generated values for age, height and weight. The instances of classPerson
are stored in a JDKList
and an Eclipse CollectionsMutableList
Both of these benchmarks use throughput in seconds for the values output (operations per second). This means the bigger the numbers, the better the performance. You should be able to execute these benchmarks after compiling the code and running the main() method in each class. You can use these tests as examples to write your own benchmarks.