Kotlin / kotlinx-benchmark

Kotlin multiplatform benchmarking toolkit
Apache License 2.0
477 stars 36 forks source link

How to set Up a Separate Source Set for Benchmarks with an ios/main module #222

Open vanniktech opened 1 month ago

vanniktech commented 1 month ago

I have a module with iOS & Android and I'd like to benchmark the commonMain code that gets run on both iOS & Android. There's a docu for Kotlin/JVM project, but I can't seem to find the missing pieces to configure the benchmarking for my module, so far I have this:

kotlin {
+  val commonBench by creating {
+    dependsOn(commonMain)
+    dependencies {
+      implementation(libs.kotlinx.benchmark.runtime)
+    }
+  }
+
+  val androidBench by creating {
+    dependsOn(commonBench)
+    dependsOn(androidMain)
+  }
}

+benchmark {
+  targets {
+    register("androidBench")
+  }
+}

When I sync with IntelliJ I am getting:

The following Kotlin source sets were configured but not added to any Kotlin compilation:
 * androidBench
 * commonBench
You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See https://kotl.in/connecting-source-sets

I've tried a few ways on how to do this in my set up but none worked:

sourceSets {
    create("benchmark")
}

I would expect that my use case would work with kotlinx-benchmark which is a multiplatform benchmarking tool.

fzhinkin commented 1 month ago

@vanniktech, unfortunately, right now kotlinx-benchmark supports neither running benchmarks on iOS devices, nor on Android. There's a project aimed to support benchmarks execution on Android: https://summerofcode.withgoogle.com/programs/2024/projects/d7VH8Um1.

As of iOS, there were no activity so far (we need to check what should be done for that).

Now, to [I assume] less useful details on project configuration. For KMP projects, compilations should be configured instead of source set (see https://github.com/Kotlin/kotlinx-benchmark/blob/master/docs/separate-benchmark-source-set.md#kotlin-multiplatform-project).

vanniktech commented 1 month ago

Alright, I had assumed that from the description Kotlin multiplatform benchmarking toolkit all targets are supported.

Would it make sense to add in this bullet list that neither android nor iOS are currently supported?

Screenshot 2024-05-29 at 20 43 55