android / android/performance-samples

Need examples on how to benchmark suspending functions in microbenchmark

Open
#232 0 comments 5 reactions 0 assignees View on GitHub
enhancement
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.