如何使用 perfasm/xperfasm/WinPerfAsmProfiler 运行 JMH

How to run JMH using perfasm/xperfasm/WinPerfAsmProfiler

尝试使用 WinPerfAsmProfiler 在 Windows 上 运行 JMH 基准测试会出现以下错误:

ERROR: No address lines detected in assembly capture, make sure your JDK is PrintAssembly-enabled:
    https://wikis.oracle.com/display/HotSpotInternals/PrintAssembly

正如 link 所暗示的那样,问题是您必须安装反汇编程序插件。有几种实现方式。然而,由于自我审查和版权纳粹主义的原因,Windows 大多数实现的二进制文件很难获得。可以找到其他信息 in this SO question (in which I've updated the suggested build steps and won't repeat them here)

您会遇到的另一个问题是您必须 运行 以管理员身份进行分析会话。

有关配置 perfasm 的系统属性的其他信息,只能在 AbstractPerfAsmProfilerWinPerfAsmProfiler 的源代码中找到(至少,从版本 1.9.2 开始)。

一个可能有用的提示:您可以在任何管理员命令提示符中通过 运行ning xperf-setprofint 1221 cached 将 xperf 的采样频率从 1KHz 增加到 8KHz(并获得更精确的计时信息)。