Skip to content

Launch benchmarks on multiple targets from a single separate source set #296

Open
@alexismanin

Description

@alexismanin

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:

  1. Applied kotlin multiplatform and kotlinx benchmark plugins
  2. registered kotlin multiplatform targets (jvm, linuxX64, js, wasmJs)
  3. applied Kotlin default hierarchy template,
  4. Defined a common main source set for my code that is not benchmark code
  5. Defined a benchmark source set that contains my Benchmark code
  6. Modified all defined targets to depend on the benchmark code (create a dedicated KotlinCompilation depending on benchmark source set)
  7. Added benchmark runtime dependency on common main implementation
  8. Defined benchmark targets : jvmBenchmark, linuxX64Benchmark, jsBenchmark, wasmJsBenchmark

Regards,

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions