Can anyone who has implemented JMH or kotlinx.Benc...
# advent-of-code
n
Can anyone who has implemented JMH or kotlinx.Benchmark answer a question for me? Documentation for kotlinx.Benchmark beyond the Readme seems to be nonexistent, and the Readme is out of date, incomplete, and assumes more knowledge of Gradle than I have. There don't seem to be any YouTube videos about it and discussion in the kotlinlang Slack is old and minimal. I tried to figure it out and finally got to the point where I could create an annotated Benchmark class without the linter screaming at me. And then... nothing. I have no idea how to actually run the benchmark! How do I do that?
e
./gradlew benchmark
assuming you added the configuration to the Gradle buildscript, which I think is documented
I have a setup here that runs kotlinx.benchmark on extra sourcesets in multiple platforms: https://github.com/ephemient/aoc2022/blob/main/kt//build.gradle.kts
n
Oof. I know so little of how Gradle works. Running from Powershell failed, said it could not find the JDK. But that reminded me of the right-hand pull-out Gradle drawer in IDEA. Sure enough, there's a Benchmark task specified. Looks like I'm on the right track, though I probably have more configuration to do to get the info I want: Thanks (again!) for your help. main summary: Benchmark Mode Cnt Score Error Units Y2022D1Bench.part1 thrpt 5 3284.533 ± 98.847 ops/s Y2022D1Bench.part2 thrpt 5 3177.036 ± 65.642 ops/s
Now we're cooking! main summary: Benchmark Mode Cnt Score Error Units Y2022D1Bench.part1 avgt 5 325.472 ± 53.458 us/op Y2022D1Bench.part2 avgt 5 341.695 ± 40.829 us/op
e
possibly your powershell environment is missing
JAVA_HOME
n
It certainly is. And probably more things to boot. It's all black magic to me. I'll probably just run it from the IDE and let JetBrains do the hard thinking for me. But I really appreciate your help!
e
BTW you can take the files at
build/reports/benchmarks/***/**.json
and send them to https://jmh.morethan.io/ for a better interface (including kotlinx-benchmark's non-JMH runs, they're in a compatible format)
300 Views