gpt4 book ai didi

profiler - JMH 的 DTraceAsmProfiler 在 Mac 上失败并显示 '[sudo: a password is required'

转载 作者:行者123 更新时间:2023-12-04 17:09:53 27 4
gpt4 key购买 nike

我正在使用 DTraceAsmProfiler 在 MacOS 上运行来自 IDEA 的基准测试它失败并出现此错误:

Exception in thread "main" org.openjdk.jmh.runner.ProfilersFailedException: Profilers failed to initialize, exiting.
at org.openjdk.jmh.runner.Runner.internalRun(Runner.java:228)
at org.openjdk.jmh.runner.Runner.run(Runner.java:209)
at com.tsypanov.benchmark.BenchmarkRunner.main(BenchmarkRunner.java:45)
Caused by: org.openjdk.jmh.profile.ProfilerException: [sudo: a password is required
]
at org.openjdk.jmh.profile.DTraceAsmProfiler.<init>(DTraceAsmProfiler.java:69)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openjdk.jmh.profile.ProfilerFactory.instantiate(ProfilerFactory.java:82)
at org.openjdk.jmh.profile.ProfilerFactory.getProfiler(ProfilerFactory.java:77)
at org.openjdk.jmh.profile.ProfilerFactory.getProfilerOrException(ProfilerFactory.java:37)
at org.openjdk.jmh.runner.Runner.internalRun(Runner.java:225)
... 2 more
我的代码:
public class BenchmarkRunner {

public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(CRHMBenchmark.class.getSimpleName())
.warmupIterations(10)
.warmupTime(TimeValue.seconds(1))
.measurementIterations(10)
.measurementTime(TimeValue.seconds(1))
.addProfiler(DTraceAsmProfiler.class)
.forks(5)
.build();

new Runner(opt).run();
}
}
我也试过从终端运行它并得到同样的错误:
% java -jar target/benchmarks.jar CRHMBenchmark -f 2 -w 1s -r 1s -prof dtraceasm
Profilers failed to initialize, exiting.
[sudo: a password is required
]
以前有人遇到过吗?

最佳答案

最后我找到了解决方案:

sudo "/Users/stsypanov/Library/Java/JavaVirtualMachines/openjdk-17.0.1/Contents/Home/bin/java" -jar target/benchmarks.jar CRHMBenchmark -f 1 -w 1s -r 1s -prof dtraceasm -jvmArgsAppend "-XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly"

关于profiler - JMH 的 DTraceAsmProfiler 在 Mac 上失败并显示 '[sudo: a password is required',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69723346/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com