performance-samples icon indicating copy to clipboard operation
performance-samples copied to clipboard

Need examples on how to benchmark suspending functions in microbenchmark

Open tunjid opened this issue 1 year ago • 0 comments

Currently, when benchmarking a suspending function, I do the following:

    val benchmarkRule = BenchmarkRule()

    @Test
    fun benchmarkSubject() = benchmarkRule.measureRepeated {
        runBlocking {
            subject.suspendingFunction()
        }
    }

Is this the best way to do it? If so, can there be a helper extension like benchmarkRule.measureSuspendingRepeated?

tunjid avatar Jun 02 '23 09:06 tunjid