避免jvm热身 [英] Avoid jvm warmup

查看:116
本文介绍了避免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.

这个小案例研究中在1700次通话后,JIT编译开始了。

In this little case study the JIT compilation kicked in after 1700 calls.

这篇关于避免jvm热身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆