melix / jmh-gradle-plugin

Integrates the JMH benchmarking framework with Gradle
Apache License 2.0
676 stars 87 forks source link

Issue with Profilers perfnorm #208

Closed thangavel-projects closed 2 years ago

thangavel-projects commented 3 years ago

Thank you very much for writing awesome tool, I face issue with perfnorm profilers.

I use JDK16: java version "16.0.2" 2021-07-20 Java(TM) SE Runtime Environment (build 16.0.2+7-67) Java HotSpot(TM) 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing) OS: Mac

When i use the profilers = ['perfnorm'] I get the error. Please find the below error,

`➜ Java16Practice gradle jmh

Task :jmhRunBytecodeGenerator Processing 1 classes from /Volumes/E/Practice-Examples/Java16Practice/build/classes/java/jmh with "reflection" generator Processing 0 classes from /Volumes/E/Practice-Examples/Java16Practice/build/classes/java/test with "reflection" generator Writing out Java source to /Volumes/E/Practice-Examples/Java16Practice/build/jmh-generated-sources and resources to /Volumes/E/Practice-Examples/Java16Practice/build/jmh-generated-resources

Task :jmh FAILED Profilers failed to initialize, exiting. [Cannot run program "perf": error=2, No such file or directory]

FAILURE: Build failed with an exception.

`

It works fine for 'cl' 'stack' but NOT for perf, perfnorm, hs_gc, hs_rt, hs_thr and few others

Could you please help me with that? Thanks in advance.

SergejIsbrecht commented 2 years ago

It seems you do not have perf installed.

 !  ~  perf --version                                                                      Di 14 Dez 2021 14:36:54 CET
perf version 5.4.151

I think macOS does not have perf, but DTrace.

Example: https://github.com/Valloric/jmh-playground/blob/master/src/jmh/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java

Perf on Linux only

$ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof perf     -f 1 (Linux)
$ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof perfnorm -f 3 (Linux)
$ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof perfasm  -f 1 (Linux)

DTrace on macOS

$ java -jar target/benchmarks.jar JMHSample_35.*Atomic -prof dtraceasm -f 1 (Mac OS X)
thangavel-projects commented 2 years ago

Got it, thank you very much for your response. Cheers.