Skip to content
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

Support usages of Blackhole outside of the @Benchmark methods #253

Open
qwwdfsad opened this issue Aug 23, 2024 · 0 comments
Open

Support usages of Blackhole outside of the @Benchmark methods #253

qwwdfsad opened this issue Aug 23, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@qwwdfsad
Copy link
Member

qwwdfsad commented Aug 23, 2024

Real-world use-case: https://github.com/sellmair/evas/blob/sellmair/evas/src/commonBenchmark/kotlin/io/sellmair/evas/benchmark/events/EmitBenchmark.kt

The scenario is the following: @Setup sets up the target entity/system and sets up a data egress that is repeatedly invoked from the target benchmark method.
For the benchmark to be representative, egress should properly consume the data.

The boiled down example might be the following:

lateinit var flow: Flow<Int>

@Setup 
fun prepare(bh: Blackhole) {
    flow = createFlow().onEach { bh.consume(it) }
}

@Benchmark
fun collect() {
    // Measure collect only and the cost of the data flow
    flow.collect()
}
@qurbonzoda qurbonzoda added the enhancement New feature or request label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants