1use criterion::{black_box, criterion_group, criterion_main, Criterion};
2use tracing::{span, Level};
3
4mod shared;
5
6fn 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]
14fn mk_span(i: u64) -> tracing::Span {
15 span!(Level::TRACE, "span", i = i)
16}
17
18const N_SPANS: usize = 100;
19criterion_group!(benches, bench);
20criterion_main!(benches);
21