use std::hint::black_box;
use criterion::{Criterion, Throughput, criterion_group, criterion_main};
use executor::{ZruntimeExecutor, runtime_handle};
#[path = "common/executor.rs"]
mod executor;
fn spawn_benches(c: &mut Criterion) {
let runtime = runtime_handle();
let mut group = c.benchmark_group("spawn");
group.throughput(Throughput::Elements(100));
group.bench_function("100-tasks", |b| {
b.to_async(ZruntimeExecutor).iter(|| async {
let tasks: Vec<_> = (0..100u32)
.map(|i| runtime.spawn("bench", async move { i }))
.collect();
for task in tasks {
black_box(task.await.unwrap());
}
});
});
group.finish();
}
criterion_group!(benches, spawn_benches);
criterion_main!(benches);