I have a several heavy benchmark classes annotated with @Benchmark. After bulding jar with benchmarks I can run all of them with following command
java -Xmx4G -jar benchmarks.jar -f 1 -wi 3 -i 10
How to specify benchmarks to run, if I don't want to run all of them?
There are two ways to run the JMH benchmark, uses Maven or run it via a JMH Runner class directly. 3.1 Maven, package it as a JAR and run it via org. openjdk.
The easiest way to get started with JMH is to generate a new JMH project using the JMH Maven archetype. The JMH Maven archetype will generate a new Java project with a single, example benchmark Java class, and a Maven pom. xml file. The Maven pom.
JMH is a Java harness for building, running, and analysing nano/micro/milli/macro benchmarks written in Java and other languages targetting the JVM.
The solution was quite than easy than I thought. The important part is to start the spring-boot application when the benchmark is getting initialized. Define a class level variable for configuration context and give a reference to it during setup of the benchmark. Make a call to the bean method inside the benchmark.
This is the exact command:
java -Xmx4G -jar benchmarks.jar YourClass -f 1 -wi 3 -i 10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With