Aeteros
Aeteros

Reputation: 673

Run specific JMH benchmarks from jar

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?

Upvotes: 11

Views: 6588

Answers (3)

ThomasRS
ThomasRS

Reputation: 8287

Expanding on Aleksey's answer, use a regular expression filter on the test class name.

java -jar myJmh.jar -f 1 -wi 1 -w 10 -i 5 "JwtParseBenchmark"
java -jar myJmh.jar -f 1 -wi 1 -w 10 -i 5 "JwtClaimBenchmark"

and/or run multiple using for example

java -jar myJmh.jar -f 1 -wi 1 -w 10 -i 5 "Jwt.*Benchmark"

Upvotes: 0

ZhekaKozlov
ZhekaKozlov

Reputation: 39536

This is the exact command:

java -Xmx4G -jar benchmarks.jar YourClass -f 1 -wi 3 -i 10

Upvotes: 7

Aleksey Shipilev
Aleksey Shipilev

Reputation: 18847

When in doubt, ask for command line help. In fact, running the JAR with -h yields:

Usage: java -jar ... [regexp*] [options]
 [opt] means optional argument.
 <opt> means required argument.
 "+" means comma-separated list of values.
 "time" arguments accept time suffixes, like "100ms".

  [arguments]                 Benchmarks to run (regexp+). 

So, supplying a regular expression as the filter helps.

Upvotes: 18

Related Questions