Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run specific JMH benchmarks from jar

Tags:

java

jmh

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?

like image 796
Aeteros Avatar asked Jan 07 '16 16:01

Aeteros


People also ask

How do you run JMH benchmarks?

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.

How do I set up JMH?

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.

What is JMH in Java?

JMH is a Java harness for building, running, and analysing nano/micro/milli/macro benchmarks written in Java and other languages targetting the JVM.

How do you benchmark a spring boot application?

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.


1 Answers

This is the exact command:

java -Xmx4G -jar benchmarks.jar YourClass -f 1 -wi 3 -i 10
like image 103
ZhekaKozlov Avatar answered Oct 04 '22 07:10

ZhekaKozlov