Kotlin / kotlinx-benchmark

Kotlin multiplatform benchmarking toolkit
Apache License 2.0
499 stars 40 forks source link

Fail if iterationTime or iterationTimeUnit is provided without one another in a benchmark config #125

Closed qurbonzoda closed 1 year ago

qurbonzoda commented 1 year ago

Currently, if iterationTime is provided without iterationTimeUnit, in JVM the latter is assumed SECONDS, while in other platforms the fallback value specified in benchmark code is used.

benchmark {
    iterations = 5
    iterationTime = 10
    // iterationTimeUnit not specified
}

If iterationTimeUnit is provided without iterationTime, in JVM the former is ignored, while in other platforms the fallback value specified in benchmark code is used.

benchmark {
    iterations = 5
    iterationTimeUnit = ms
    // iterationTime not specified
}

kotlinx-benchmark-plugin should fail if the options are provided without one another. Another option is to change the iterationTime type to be a class with two properties, e.g., iterationTime = IterationTime(10, "s") or iterationTime = IterationTime(10, BenchmarkTimeUnit.SECONDS)