Skip to content

Non-JVM benchmarks fail if multiple modes are specified in BenchmarkMode annotation #174

Open
@fzhinkin

Description

@fzhinkin

BenchmarkMode annotation allows specifying multiple modes simultaneously [1], but only JVM benchmarks support it. For all other targets SuiteSourceGenerator fails as it expect at most one mode value [2]:

Execution failed for task ':benchmark:macosArm64BenchmarkGenerate'.
> There was a failure while executing work items
   > A failure occurred while executing kotlinx.benchmark.gradle.NativeSourceGeneratorWorker
      > List has more than one element.

...
Caused by: java.lang.IllegalArgumentException: List has more than one element.
        at kotlin.collections.CollectionsKt___CollectionsKt.single(_Collections.kt:610)
        at kotlinx.benchmark.gradle.SuiteSourceGenerator.generateBenchmark(SuiteSourceGenerator.kt:142)
        at kotlinx.benchmark.gradle.SuiteSourceGenerator.processPackage(SuiteSourceGenerator.kt:107)
        at kotlinx.benchmark.gradle.SuiteSourceGenerator.processPackage(SuiteSourceGenerator.kt:112)
        at kotlinx.benchmark.gradle.SuiteSourceGenerator.processPackage(SuiteSourceGenerator.kt:112)
        at kotlinx.benchmark.gradle.SuiteSourceGenerator.processPackage(SuiteSourceGenerator.kt:112)
        at kotlinx.benchmark.gradle.SuiteSourceGenerator.processPackage(SuiteSourceGenerator.kt:112)
        at kotlinx.benchmark.gradle.SuiteSourceGenerator.processPackage(SuiteSourceGenerator.kt:112)
        at kotlinx.benchmark.gradle.SuiteSourceGenerator.generate(SuiteSourceGenerator.kt:80)
        at kotlinx.benchmark.gradle.NativeSourceGeneratorWorker.execute(NativeSourceGeneratorTask.kt:78)
...

Multiple modes should be either supported across all targets, or the BenchmarkMode annotation should only accept a single argument in non-JVM source sets.

[1]

expect annotation class BenchmarkMode(vararg val value: Mode)

[2] https://github.com/Kotlin/kotlinx-benchmark/blob/3f32f2d9d9732a2a01d231134c52e6554428b519/plugin/main/src/kotlinx/benchmark/gradle/SuiteSourceGenerator.kt#L142C19-L142C19

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions