Kotlin / kotlinx-benchmark

Kotlin multiplatform benchmarking toolkit
Apache License 2.0
498 stars 40 forks source link

Setup JHM profiler #50

Open mcpiroman opened 3 years ago

mcpiroman commented 3 years ago

For Jvm-only setup, can I use profiler as described in https://github.com/openjdk/jmh/blob/master/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_35_Profilers.java?

elect86 commented 2 years ago

Any news on this?

max-kammerer commented 2 years ago

@mcpiroman @elect86 Could you clarify your questions? There is simple example with JMH https://github.com/Kotlin/kotlinx-benchmark/blob/master/examples/java/, maybe it could answer your question?

elect86 commented 2 years ago

Nope, this is what we'd like

max-kammerer commented 2 years ago

@elect86 Sorry, but pointing to line doesn't explain your problem and difficulties. Could you explain them?

elect86 commented 2 years ago

Ok, I'll try to explain better.

From the main docs in the sample

JMH has a few very handy profilers that help to understand your benchmarks. While these profilers are not the substitute for full-fledged external profilers, in many cases, these are handy to quickly dig into the benchmark behavior. When you are doing many cycles of tuning up the benchmark code itself, it is important to have a quick turnaround for the results.

Among these, there is for example one regarding the GC. You can use it by passing -prof gc on the cli. It'll print something like here:

Benchmark Mode Cnt Score Error Units

ScalarReplacement.single avgt 15 1.919 ± 0.002 ns/op ScalarReplacement.single:·gc.alloc.rate avgt 15 ≈ 10⁻⁴ MB/sec ScalarReplacement.single:·gc.alloc.rate.norm avgt 15 ≈ 10⁻⁶ B/op ScalarReplacement.single:·gc.count avgt 15 ≈ 0 counts

It's useful to check, for example, if the EA kicks in and helps avoiding allocations

I'd like to have the possibility to set it in kotlinx-benchmark as well. I tried param and advanced, but it didn't work

max-kammerer commented 2 years ago

@elect86 Thank you for clarification! I hope @qurbonzoda could answer your question after coming back from vacation

guohao commented 2 years ago

Profiler is a very important feature for JMH users, hope to support soon :)

qurbonzoda commented 2 years ago

Hi everyone, You can still run a specific profiler (-prof <profiler>) by running the jar file that the <target>BenchmarkJar task generates. The generated jar file is located under the build/benchmarks/<target>/jars directory.

Currently, there is no way to define a profiler in the configuration script. Would a configuration option be helpful for you?