diff options
Diffstat (limited to 'third_party/rust/tracing/benches/span_repeated.rs')
-rw-r--r-- | third_party/rust/tracing/benches/span_repeated.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/third_party/rust/tracing/benches/span_repeated.rs b/third_party/rust/tracing/benches/span_repeated.rs new file mode 100644 index 0000000000..4c6ac409d8 --- /dev/null +++ b/third_party/rust/tracing/benches/span_repeated.rs @@ -0,0 +1,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); |