Run specific JMH benchmarks from jar

2019-07-07 08:08发布

问题:

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?

回答1:

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.



回答2:

This is the exact command:

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


标签: java jmh