1 | use criterion::{black_box, criterion_group, criterion_main, Criterion}; |
2 | use tracing::{span, Level}; |
3 | |
4 | mod shared; |
5 | |
6 | fn bench(c: &mut Criterion) { |
7 | shared::for_all_recording(&mut c.benchmark_group("span_repeated" ), |b| { |
8 | let n = black_box(N_SPANS); |
9 | b.iter(|| (0..n).fold(mk_span(0), |_, i| mk_span(i as u64))) |
10 | }); |
11 | } |
12 | |
13 | #[inline ] |
14 | fn mk_span(i: u64) -> tracing::Span { |
15 | span!(Level::TRACE, "span" , i = i) |
16 | } |
17 | |
18 | const N_SPANS: usize = 100; |
19 | criterion_group!(benches, bench); |
20 | criterion_main!(benches); |
21 | |