JVM 禁用特定 class 或方法的内联
JVM disable inlining for a particular class or method
我正在尝试编写一些基准测试来衡量内联方法的效果。有人知道是否可以禁用 HostSpot JVM 上特定 class 或方法的内联吗?
我发现 -XX:-Inline
完全禁用了内联。
您可以使用 -XX:CompileCommand
JVM 选项来控制即时编译。该选项可用于排除要编译的某些方法(或 class 的所有方法)等。来自 documentation:
Specifies a command to perform on a method. For example, to exclude the indexOf()
method of the String class from being compiled, use the following:
-XX:CompileCommand=exclude,java/lang/String.indexOf
如果你只想防止方法内联,你可以使用具有相同语法的dontinline
命令,例如
-XX:CompileCommand=dontinline,java/lang/String.indexOf
流行的 Java 微基准测试工具 JMH.
在内部使用相同的 JVM 选项
我正在尝试编写一些基准测试来衡量内联方法的效果。有人知道是否可以禁用 HostSpot JVM 上特定 class 或方法的内联吗?
我发现 -XX:-Inline
完全禁用了内联。
您可以使用 -XX:CompileCommand
JVM 选项来控制即时编译。该选项可用于排除要编译的某些方法(或 class 的所有方法)等。来自 documentation:
Specifies a command to perform on a method. For example, to exclude the
indexOf()
method of the String class from being compiled, use the following:
-XX:CompileCommand=exclude,java/lang/String.indexOf
如果你只想防止方法内联,你可以使用具有相同语法的dontinline
命令,例如
-XX:CompileCommand=dontinline,java/lang/String.indexOf
流行的 Java 微基准测试工具 JMH.
在内部使用相同的 JVM 选项