1use criterion::{black_box, criterion_group, criterion_main, Criterion};
2
3fn bench(c: &mut Criterion) {
4 use std::sync::atomic::{AtomicUsize, Ordering};
5
6 let mut group = c.benchmark_group("comparison");
7 group.bench_function("relaxed_load", |b| {
8 let foo = AtomicUsize::new(1);
9 b.iter(|| black_box(foo.load(Ordering::Relaxed)));
10 });
11 group.bench_function("acquire_load", |b| {
12 let foo = AtomicUsize::new(1);
13 b.iter(|| black_box(foo.load(Ordering::Acquire)))
14 });
15 group.bench_function("log", |b| {
16 b.iter(|| {
17 log::log!(log::Level::Info, "log");
18 })
19 });
20 group.finish();
21}
22
23criterion_group!(benches, bench);
24criterion_main!(benches);
25