Separating source sets for benchmarks in multiplatform projects
See original GitHub issueI’ve tried adding:
val commonBenchmark by creating {
dependsOn(commonMain) // or commonTest
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.3.1")
implementation("com.goncalossilva:resources:0.2.1")
}
}
And then configuring targets as documented:
benchmark {
targets {
register("js")
// register("jvm")
// ...
}
}
But this is clearly not the right way, since nothing happens when running (“Test events were not received”) and there is this warning:
The Kotlin source set commonBenchmark was configured but not added to any Kotlin compilation. You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
BUILD SUCCESSFUL in 5s
1 actionable task: 1 executed
> Task :assembleBenchmarks UP-TO-DATE
> Task :kotlinNpmCachesSetup
> Task :jsPackageJson
> Task :kotlinNodeJsSetup UP-TO-DATE
> Task :kotlinYarnSetup UP-TO-DATE
> Task :jsBenchmarkPackageJson UP-TO-DATE
> Task :rootPackageJson
> Task :kotlinNpmInstall
> Task :jsGenerateExternalsIntegrated SKIPPED
> Task :compileKotlinJs UP-TO-DATE
> Task :jsProcessResources NO-SOURCE
> Task :jsMainClasses UP-TO-DATE
> Task :jsBenchmarkGenerate UP-TO-DATE
> Task :compileBenchmarkKotlinJs NO-SOURCE
> Task :jsBenchmark SKIPPED
> Task :benchmark UP-TO-DATE
BUILD SUCCESSFUL in 723ms
9 actionable tasks: 4 executed, 5 up-to-date
23:44:03: Execution finished 'benchmark'
Could this be documented?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Jvm bench in multiplatform with separate SourceSet ... - GitHub
I'm trying to benchmark jvm on a multiplatform project with separate sourceSet To reproduce just clone this branch This is my setup so...
Read more >Kotlin multiplatform benchmarking toolkit - Android Example 365
kotlinx.benchmark is a toolkit for running benchmarks for multiplatform code written in Kotlin and running on the next supported targets: JVM, ...
Read more >Support hierarchical project structure of multiplatform projects ...
The subject is about multiplatform projects which have intermediate platfrom-agnostic source sets in the hierarchy between the default common ones ( commonMain ...
Read more >Understand Multiplatform project structure - Kotlin
Source sets form a hierarchy, which is used for sharing the common code. In a source set shared among several targets, you can...
Read more >Configuring a multiplatform app - Apple Developer
By default, apps that share a multiplatform target share project settings, so you only need to set ... Otherwise, use a separate target...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Copied more directly from my actual project which uses the name “bench”, not “benchmark”; perhaps the latter conflicts with some things kotlinx-benchmark sets up itself. (You did remove
register("js")though, right?)Yeah the docs aren’t explicit about how to do it, but you need to create a compilation for that sourceset.