JMH java基准测试
作者:互联网
maven依赖
<dependencies> <dependency> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-core</artifactId> <version>${jmh.version}</version> </dependency> <dependency> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-generator-annprocess</artifactId> <version>${jmh.version}</version> <scope>provided</scope> </dependency> </dependencies> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <jmh.version>1.0</jmh.version> <javac.target>1.6</javac.target> <uberjar.name>benchmarks</uberjar.name> </properties>
命令行方式:
生成测试项目
mvn archetype:generate \ -DinteractiveMode=false \ -DarchetypeGroupId=org.openjdk.jmh \ -DarchetypeArtifactId=jmh-java-benchmark-archetype \ -DgroupId=org.sample \ -DartifactId=test \ -Dversion=1.0
打包
$ cd test/ $ mvn clean install
执行,
java -jar target/benchmarks.jar
java -jar target/benchmarks.jar -h //查看帮助信息
插件方式
插件会影响执行效果,但最多不会超过 2.2%
A brief research shows that benchmark results are affected, but not that much. The whole research is described in Research results.
Long story short, the maximum means difference observed was 2.2%.
参加链接:
http://openjdk.java.net/projects/code-tools/jmh/
标签:插件,java,基准,jar,JMH,jmh,org,openjdk 来源: https://www.cnblogs.com/siqi/p/12038557.html