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 预热
基础教程推荐
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 降序排序:Java Map 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01