如何检查 JIT 编译器是否在 Java 中关闭

2023-10-14Java开发问题
0

本文介绍了如何检查 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 中关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何使用 JAVA 向 COM PORT 发送数据?
How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)...
2024-08-25 Java开发问题
21

如何使报表页面方向更改为“rtl"?
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)...
2024-08-25 Java开发问题
19

在 Eclipse 项目中使用西里尔文 .properties 文件
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)...
2024-08-25 Java开发问题
18

有没有办法在 Java 中检测 RTL 语言?
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)...
2024-08-25 Java开发问题
11

如何在 Java 中从 DB 加载资源包消息?
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)...
2024-08-25 Java开发问题
13

如何更改 Java 中的默认语言环境设置以使其保持一致?
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)...
2024-08-25 Java开发问题
13