A maven plugin for jmh benchmark test(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.
<plugin>
<groupId>com.baidu.maven</groupId>
<artifactId>jmh-maven-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>jmh</goal>
</goals>
</execution>
</executions>
<configuration>
<forks>1</forks>
<warmupForks>1</warmupForks>
<threads>1</threads>
<mode>thrpt</mode>
<timeUnit>s</timeUnit>
<measurementTime>1s</measurementTime>
<warmupTime>1s</warmupTime>
<resultFormat>json</resultFormat>
<resultFile>benchmark_json_result</resultFile>
</configuration>
</plugin>mvn clean test
follow paramter could close benchmark test action at command line
mvn clean test -DskipBenchmark
| 参数名 | 默认值 | 说明 |
|---|---|---|
| forks | 1 | Number of forks to use in the run |
| warmupForks | 1 | Number of forks to use in warm up action |
| threads | 1 | Number of threads to run the benchmark in |
| mode | thrpt | Benchmark mode. thrpt(Throughput) avgt(AverageTime) sample(SampleTime) ss(SingleShotTime) all(All) |
| timeUnit | s | Timeunit to use in results. ns ms us s m |
| measurementTime | 1s | How long each measurement iteration should take? day, hr, us, ms, min, ns, s |
| warmupTime | 1s | How long each warmup iteration should take? day, hr, us, ms, min, ns, s |
| timeout | 10s | How long to wait for iteration execution day, hr, us, ms, min, ns, s (since 1.0.3) |
| measurementIterations | 5 | How many measurement measurementIterations to do |
| warmupIterations | 3 | How many warmup iterations to do? |
| resultFormat | JSON | ResultFormatType to use in the run TEXT, CSV, SCSV, JSON, LATEX, |
| resultFile | Output filename to write the result to maven target output 使用JMH可视化工具打开:jmh-visual-chart 或者 jmh-visualizer | |
| benchmarkIncludes | Include benchmark in the run. multiple split by ";" | |
| warmUpBenchmarkIncludes | What other benchmarks to warmup along the way. multiple split by ";" | |
| multiResultFileOutput | false | Output split result file from benchmarkIncludes (since 1.0.3) |