Skip to content

How can I run benchmarks on cold start? #273

Open
@dmitry-stakhov

Description

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
    }
}

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions