How to check if the JIT compiler is off in Java(如何检查 JIT 编译器是否在 Java 中关闭)
问题描述
我想知道如何检查 JIT 编译器是否已关闭.我有以下代码,旨在关闭 JIT 编译器.问题是,我不确定它是否真的这样做.所以我想知道是否有办法检查 JIT 是否关闭.我查看了 Compiler 类,但没有像 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 程序进行基准测试,您绝对应该忽略前几次运行.在 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.
我推荐使用 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.
这篇关于如何检查 JIT 编译器是否在 Java 中关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何检查 JIT 编译器是否在 Java 中关闭
基础教程推荐
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01