Avoid jvm warmup(避免 jvm 预热)
问题描述
如果我正在设计排序算法测试,我可以这样做以避免 JVM 预热吗?谢谢!
If I am designing a test on sorting algorithm can I do this way to avoid JVM warmup ? Thank you!
double count = 0;
double start, end;
for(int r = 0; r < warmup; r++) {
// do test
}
for(int t = 0; t < runs; t++){
start = System.nanoTime();
// do test
end = System.nanoTime();
count += start - end;
}
double avg = count/avg
推荐答案
JVM预热通常是指JVM找到热点并JIT这些代码段所花费的时间.如果你实际运行几百次(我相信实际上是几千次)测试,你应该会很好.
The JVM warmup usually refers to the time it takes for the JVM to find the hotspots and JIT these sections of the code. If you run your actual tests a few hundred (actually a few thousand I believe) times you should be fairly good to go.
但是,您应该知道,即使您这样做,也无法保证.您必须对特定的 JVM 进行试验,以确定在重要部分被 JIT 等之前您需要做多少工作.
You should however know that, even if you do this, there are no guarantees. You'll have to experiment with your particular JVM to figure out how much work you have to do before the vital parts is JITed and so on.
在这个小案例研究中JIT 编译在 1700 次调用后开始.
In this little case study the JIT compilation kicked in after 1700 calls.
这篇关于避免 jvm 预热的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:避免 jvm 预热


- C++ 和 Java 进程之间的共享内存 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01