本文介绍了为什么JMH会运行不同的叉子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JMH基准测试框架()在我的代码上运行基准测试。我的理解是JMH在基准测试期间多次分配JVM,以便丢弃由JVM在执行期间执行的即时(JIT)分析构建的任何配置文件。

I am using the JMH benchmarking framework (http://openjdk.java.net/projects/code-tools/jmh/) to run benchmarks on my code. My understanding is that JMH forks the JVM multiple times during benchmarking in order to discard any profiles built up by the just-in-time (JIT) profiling performed by the JVM during execution.

我理解为什么这在某些情况下很有用,例如下面的内容(从):

I understand why this is useful in some cases such as the below (copied verbatim from http://java-performance.info/jmh/):

但是,在您进行基准测试的情况下重复使用相同的代码是否有任何优势来运行10个叉子,每个20次迭代,而不是1次叉子,200次迭代?

However, in the case where you are benchmarking the same code repeatedly is there any advantage to running say 10 forks of 20 iterations each instead of 1 fork with 200 iterations?

非常感谢,

Danny

推荐答案

有人坚持使用分叉解决另一个问题是逐次运行的差异:

Some people insist that another problem solved by using forks is run-to-run variance: http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java

但是,任何认真的工程师必须能够对基准测试环境进行足够的控制,以消除运行之间的任何差异。看到人们使用叉子来克服他们的懒惰或者对他们的基准实际执行方式缺乏了解是令人沮丧的。

However, any serious engineer must be able to exercise sufficient control over the benchmarking environment to eliminate any difference between runs. It is disheartening to see people using forks to overcome their laziness or lack of understanding of how their benchmarks are actually executed.

这篇关于为什么JMH会运行不同的叉子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 17:26