fabaccess-bffh/runtime/executor/benches/perf.rs

23 lines
502 B
Rust
Raw Normal View History

use criterion::{black_box, criterion_group, criterion_main, Criterion};
2022-05-05 15:50:44 +02:00
use executor::prelude::*;
2021-11-14 17:51:48 +01:00
fn increment(b: &mut Criterion) {
2021-11-14 17:51:48 +01:00
let mut sum = 0;
let executor = Executor::new();
2021-11-14 17:51:48 +01:00
2022-05-05 15:50:44 +02:00
b.bench_function("Executor::run", |b| {
b.iter(|| {
executor.run(async {
2021-11-14 17:51:48 +01:00
(0..10_000_000).for_each(|_| {
sum += 1;
});
2022-05-05 15:50:44 +02:00
});
})
});
2021-11-14 17:51:48 +01:00
black_box(sum);
}
criterion_group!(perf, increment);
2022-05-05 15:50:44 +02:00
criterion_main!(perf);