Open
Description
I've used https://github.com/fzhinkin/benchmarks-template.
@State(Scope.Benchmark)
open class ExampleBenchmark {
@Benchmark
fun parse() =
@OptIn(ExperimentalTime::class) Instant.parse("2023-10-01T16:12:42.546124Z")
@Benchmark
fun parseNoFrac() =
@OptIn(ExperimentalTime::class) Instant.parse("2023-10-01T16:12:42Z")
}
then fails to compile with
> Task :compileJsBenchmarkKotlinJs FAILED
e: file:///home/jb/IdeaProjects/benchmark-Instant-parse/build/benchmarks/js/sources/kotlinx/benchmark/generated/org/example/ExampleBenchmark_Descriptor.kt:30:52 This declaration needs opt-in. Its usage must be marked with '@kotlin.time.ExperimentalTime' or '@OptIn(kotlin.time.ExperimentalTime::class)'
e: file:///home/jb/IdeaProjects/benchmark-Instant-parse/build/benchmarks/js/sources/kotlinx/benchmark/generated/org/example/ExampleBenchmark_Descriptor.kt:32:52 This declaration needs opt-in. Its usage must be marked with '@kotlin.time.ExperimentalTime' or '@OptIn(kotlin.time.ExperimentalTime::class)'
Moving OptIn
somewhere outside also causes the compilation failure. The one way I've found to write this benchmark is to use block bodies for these functions:
@Benchmark
fun parse() {
@OptIn(ExperimentalTime::class) Instant.parse("2023-10-01T16:12:42.546124Z")
}