如何检查Java中的JIT编译器是否关闭 [英] How to check if the JIT compiler is off in Java

查看:455
本文介绍了如何检查Java中的JIT编译器是否关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何检查JIT编译器是否关闭。我有以下代码,这意味着关闭JIT编译器。问题是,我不知道如果它是真的这样做。所以我想知道是否有一种方法来检查JIT是否关闭。
我查看了编译器类,但没有任何方法 isDisabled / enabled()

I would like to know how to check if the JIT compiler is turned off. I have the following code which is meant to turn the JIT compiler off.The problem is, I am not sure if it is actually doing that. So I was wondering if there is a way of checking if the JIT is off. I looked at the Compiler class but there isn't any method like isDisabled/enabled().

代码:

Compiler.disable();  

任何帮助或指导将非常感激。

Any help or direction will be highly appreciated.

推荐答案

我不相信你可以在运行时关闭JIT。

I don't believe you can turn the JIT off at runtime.

程序,你肯定会忽略前几个运行。在Java中获得可靠的基准测试是一个非常棘手的事情,最好留给比你或我更聪明的人。

If you want to seriously benchmark a Java program, you should definitely be ignoring the first few runs. Getting reliable benchmarks in Java is an extremely tricky business, best left to people much smarter than you or I.

我建议使用< =http://caliper.googlecode.com> Caliper ,它在Google内部用于微基准测试,并且对于预热JIT和其他东西非常有用。具体来说,查看此处的示例,其中显示了如何衡量不同输入大小的算法的效率。

I recommend using Caliper, which is used internally at Google for microbenchmarking and is plenty smart about warming up the JIT and stuff. In particular, look at the example here, which shows how to measure the efficiency of an algorithm for different input sizes.

这篇关于如何检查Java中的JIT编译器是否关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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