android / android/performance-samples
Need examples on how to benchmark suspending functions in microbenchmark
- Dominant language
- Kotlin
- Stars
- 1.4k
- Forks
- 250
- Avg merge
- 9m
- Merged PRs (30d)
- 4
Description
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`?
Contributor guide
Research direction
Start by reviewing the existing BenchmarkRule.measureRepeated and runBlocking usage shown in the issue, then locate the microbenchmark examples and related tests in the repository. Done means establishing the recommended approach for suspending functions and, if appropriate, adding a helper or example with coverage for the intended usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100