kotlinx-benchmark icon indicating copy to clipboard operation
kotlinx-benchmark copied to clipboard

How can I run benchmarks on cold start?

Open dmitry-stakhov opened this issue 1 year ago • 6 comments
trafficstars

In the next snippet the code I want to benchmark is called only on the first benchmark iteration. How can I make it to be called on each iteration on JVM and native targets?

object Init {
    val value = doSomeInit().apply {
        println("INIT")
    }

    private fun doSomeInit() = 1 + 1
}


@State(Scope.Benchmark)
class NetworkingBenchmark {
    @Benchmark
    fun runBenchmark() {
        Init.value
    }
}

dmitry-stakhov avatar Nov 05 '24 07:11 dmitry-stakhov