Description
Is it possible to create a single benchmark class in a dedicated source set, and then define multiple benchmark targets (one for each kotlin multiplatform compilation target in the project) to launch the same benchmark ?
I am currently trying to achieve that in this little Github project (currently on a dedicated refactor/kotlinx-benchmark
branch).
So far, I succeeded to launch my benchmark from a separate source set on JVM target only. All other targets launches, but no benchmark is executed for them.
I have not found any example that do exactly that, so I am wondering if it is currently achievable. If not, what are the alternatives ? Would it work if I move my benchmarks in "commonMain" source set ?
For reference, here is what I've tried:
I've set up my build file by mixing information from doc: separate benchmark source set and this issue about simplifying separate source-set.
Therefore, I've:
- Applied kotlin multiplatform and kotlinx benchmark plugins
- registered kotlin multiplatform targets (jvm, linuxX64, js, wasmJs)
- applied Kotlin default hierarchy template,
- Defined a common main source set for my code that is not benchmark code
- Defined a
benchmark
source set that contains my Benchmark code - Modified all defined targets to depend on the benchmark code (create a dedicated KotlinCompilation depending on benchmark source set)
- Added benchmark runtime dependency on common main implementation
- Defined benchmark targets :
jvmBenchmark
,linuxX64Benchmark
,jsBenchmark
,wasmJsBenchmark
Regards,