kotlinx-benchmark
kotlinx-benchmark copied to clipboard
How to benchmark jdk.incubator (jvm)
I am trying to benchmark code that uses jdk.incubator.vector methods, but this raises an error in :jvmBenchmarkGenerate:
Generation of JMH bytecode failed with 1errors:
- Annotation generator had thrown the exception.
java.lang.NoClassDefFoundError: jdk/incubator/vector/VectorSpecies
A minimal benchmark code is
@State(Scope.Benchmark)
open class MyBenchmark {
val species: VectorSpecies<Long> = LongVector.SPECIES_PREFERRED
@Benchmark fun test() = species.length()
}
I have tried adding @Fork(jvmArgs = ["--add-modules", "jdk.incubator.vector"]) and also added to build.gradle.kts:
tasks.withType<JavaExec> {
if (name == "jvmBenchmark") {
jvmArgs(listOf("--add-modules", "jdk.incubator.vector"))
}
}
but without success.
Hi, could you able to solve this issue (for multiplatform setup)?.. i am slo facing the same issue when using vector APIs with jdk 21.
No, in the end I used conventional time measurement (after some warming-up loops). My test cases were simple Boolean operations on large bitsets. I could not identify a performance gain, so I went back to conventional code. However, results may depend on your CPU architecture and I used an older jdk version.
Thanks...eventually i could able to run with @Fork(value = 1, jvmArgsAppend = ["--add-modules=jdk.incubator.vector"]) and some kotlin mpp compileJava and test configurations . Wish the framework had builtin support to configure more JMH parameters instead of hardcoding it in the Benchmark tests.
Edit: sorry, no this is not working as expected :/