Run specific JMH benchmarks from jar
Asked Answered
D

3

10

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?

Dessau answered 7/1, 2016 at 16:42 Comment(0)
K
18

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.

Kenton answered 7/1, 2016 at 16:47 Comment(0)
B
7

This is the exact command:

java -Xmx4G -jar benchmarks.jar YourClass -f 1 -wi 3 -i 10
Bimonthly answered 6/3, 2017 at 11:17 Comment(5)
Code only answers are discouraged. Please include a brief explanation of how/why the above helps solve the problem. From Review.Plebiscite
@Plebiscite There is no problem. Just a simple question to which I give a simple answer.Bimonthly
Simple to you perhaps :) Not everyone reading this will have the same skill level. So adding a brief explanation makes it more helpful, to a broader range of users.Plebiscite
@Leight The other answer already has an explanation which I don't want to repeat. My answer adds a precise command to run which is missing in that answer.Bimonthly
It is up to you. Anyway, I get what you mean and do not want keep "beating a dead horse" ;-)Plebiscite
P
0

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"
Penumbra answered 16/1, 2021 at 19:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.