summaryrefslogtreecommitdiffstats
path: root/vendor/tracing-subscriber/benches/enter.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/tracing-subscriber/benches/enter.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/tracing-subscriber/benches/enter.rs')
-rw-r--r--vendor/tracing-subscriber/benches/enter.rs64
1 files changed, 64 insertions, 0 deletions
diff --git a/vendor/tracing-subscriber/benches/enter.rs b/vendor/tracing-subscriber/benches/enter.rs
new file mode 100644
index 000000000..49c6e730a
--- /dev/null
+++ b/vendor/tracing-subscriber/benches/enter.rs
@@ -0,0 +1,64 @@
+use criterion::{criterion_group, criterion_main, Criterion};
+use tracing_subscriber::prelude::*;
+
+fn enter(c: &mut Criterion) {
+ let mut group = c.benchmark_group("enter");
+ let _subscriber = tracing_subscriber::fmt()
+ .with_max_level(tracing::Level::INFO)
+ .finish()
+ .set_default();
+ group.bench_function("enabled", |b| {
+ let span = tracing::info_span!("foo");
+ b.iter_with_large_drop(|| span.enter())
+ });
+ group.bench_function("disabled", |b| {
+ let span = tracing::debug_span!("foo");
+ b.iter_with_large_drop(|| span.enter())
+ });
+}
+
+fn enter_exit(c: &mut Criterion) {
+ let mut group = c.benchmark_group("enter_exit");
+ let _subscriber = tracing_subscriber::fmt()
+ .with_max_level(tracing::Level::INFO)
+ .finish()
+ .set_default();
+ group.bench_function("enabled", |b| {
+ let span = tracing::info_span!("foo");
+ b.iter(|| span.enter())
+ });
+ group.bench_function("disabled", |b| {
+ let span = tracing::debug_span!("foo");
+ b.iter(|| span.enter())
+ });
+}
+
+fn enter_many(c: &mut Criterion) {
+ let mut group = c.benchmark_group("enter_many");
+ let _subscriber = tracing_subscriber::fmt()
+ .with_max_level(tracing::Level::INFO)
+ .finish()
+ .set_default();
+ group.bench_function("enabled", |b| {
+ let span1 = tracing::info_span!("span1");
+ let _e1 = span1.enter();
+ let span2 = tracing::info_span!("span2");
+ let _e2 = span2.enter();
+ let span3 = tracing::info_span!("span3");
+ let _e3 = span3.enter();
+ let span = tracing::info_span!("foo");
+ b.iter_with_large_drop(|| span.enter())
+ });
+ group.bench_function("disabled", |b| {
+ let span1 = tracing::info_span!("span1");
+ let _e1 = span1.enter();
+ let span2 = tracing::info_span!("span2");
+ let _e2 = span2.enter();
+ let span3 = tracing::info_span!("span3");
+ let _e3 = span3.enter();
+ let span = tracing::debug_span!("foo");
+ b.iter_with_large_drop(|| span.enter())
+ });
+}
+criterion_group!(benches, enter, enter_exit, enter_many);
+criterion_main!(benches);