1use criterion::{black_box, criterion_group, criterion_main, Criterion};
2
3mod shared;
4
5fn bench(c: &mut Criterion) {
6 let mut group = c.benchmark_group("empty_span");
7 shared::for_all_dispatches(&mut group, |b| {
8 b.iter(|| {
9 let span = tracing::span::Span::none();
10 black_box(&span);
11 })
12 });
13 group.bench_function("baseline_struct", |b| {
14 b.iter(|| {
15 let span = FakeEmptySpan::new();
16 black_box(&span);
17 })
18 });
19}
20
21struct FakeEmptySpan {
22 inner: Option<(usize, std::sync::Arc<()>)>,
23 meta: Option<&'static ()>,
24}
25
26impl FakeEmptySpan {
27 fn new() -> Self {
28 Self {
29 inner: None,
30 meta: None,
31 }
32 }
33}
34
35impl Drop for FakeEmptySpan {
36 fn drop(&mut self) {
37 black_box(&self.inner);
38 black_box(&self.meta);
39 }
40}
41
42criterion_group!(benches, bench);
43criterion_main!(benches);
44