-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I run benchmarks on cold start? #273
Comments
@dmitry-stakhov, on JVM, you can use JMH's |
@fzhinkin I tried this, but still init is called only once. // in test gradle module
object Test {
val test = 1.apply {
println("INIT")
}
} // in benchmark Gradle module
import kotlinx.benchmark.Benchmark
import kotlinx.benchmark.BenchmarkMode
import kotlinx.benchmark.Scope
import kotlinx.benchmark.State
import org.openjdk.jmh.annotations.Mode.SingleShotTime
@State(Scope.Benchmark)
@BenchmarkMode(SingleShotTime)
class ObjectBenchmark {
@Benchmark
fun objectBenchmark() {
val a = Test.test
}
}
|
@akiya-nagatsuka, given multiple warmup and measurement iterations, it seems like I took the benchmark as it is and ss-mode worked as expected:
Maybe you can share a project so we could figure out why the benchmark does not behave as it should for you? |
@fzhinkin |
Following config overrides benchmark's settings:
If you need to run benchmarks via Gradle tasks, (as a workaround) you can add a configuration like that:
and it'll do the trick:
|
But in general, it might be worth providing a single-shot / cold-start benchmarking mode for all supported targets in the future. (CC @qurbonzoda) |
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?
The text was updated successfully, but these errors were encountered: