Java Performance measurement

前端 未结 6 964
被撕碎了的回忆
被撕碎了的回忆 2020-12-10 03:53

I am doing some Java performance comparison between my classes, and wondering if there is some sort of Java Performance Framework to make writing performance measurement cod

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 04:03

    OpenJDK guys have developed a benchmarking tool called JMH:

    http://openjdk.java.net/projects/code-tools/jmh/

    This provides quite an easy to setup framework, and there is a couple of samples showing how to use that.

    http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/

    Nothing can prevent you from writing the benchmark wrong, but they did a great job at eliminating the non-obvious mistakes (such as false sharing between threads, preventing dead code elimination etc).

提交回复
热议问题