summaryrefslogtreecommitdiffstats
path: root/third_party/rust/tracing/benches/span_repeated.rs
blob: 4c6ac409d89a0dd3e062614b5c418c531bc71409 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use tracing::{span, Level};

mod shared;

fn bench(c: &mut Criterion) {
    shared::for_all_recording(&mut c.benchmark_group("span_repeated"), |b| {
        let n = black_box(N_SPANS);
        b.iter(|| (0..n).fold(mk_span(0), |_, i| mk_span(i as u64)))
    });
}

#[inline]
fn mk_span(i: u64) -> tracing::Span {
    span!(Level::TRACE, "span", i = i)
}

const N_SPANS: usize = 100;
criterion_group!(benches, bench);
criterion_main!(benches);