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