Skip to content

Commit

Permalink
Add flamegraph for some benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas committed Jun 27, 2024
1 parent 4df74e8 commit 28fc70a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
3 changes: 3 additions & 0 deletions opentelemetry-appender-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ tracing-log = "0.2"
async-trait = { workspace = true }
criterion = { workspace = true }

[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
pprof = { version = "0.13", features = ["flamegraph", "criterion"] }

[features]
experimental_metadata_attributes = ["dep:tracing-log"]
logs_level_enabled = ["opentelemetry/logs_level_enabled"]
Expand Down
14 changes: 13 additions & 1 deletion opentelemetry-appender-tracing/benches/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use async_trait::async_trait;
use criterion::{criterion_group, criterion_main, Criterion};
use pprof::criterion::{Output, PProfProfiler};
use opentelemetry::logs::LogResult;
use opentelemetry::KeyValue;
use opentelemetry_appender_tracing::layer as tracing_layer;
Expand Down Expand Up @@ -173,5 +174,16 @@ fn criterion_benchmark(c: &mut Criterion) {
benchmark_with_noop_layer(c, false, "noop_layer_disabled");
}

criterion_group!(benches, criterion_benchmark);
#[cfg(not(target_os = "windows"))]
criterion_group! {
name = benches;
config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = criterion_benchmark
}
#[cfg(target_os = "windows")]
criterion_group! {
name = benches;
config = Criterion::default();
targets = criterion_benchmark
}
criterion_main!(benches);
17 changes: 14 additions & 3 deletions opentelemetry-sdk/benches/metric_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use opentelemetry::{
KeyValue,
};
use opentelemetry_sdk::metrics::{ManualReader, SdkMeterProvider};
use pprof::criterion::{Output, PProfProfiler};
use rand::{
rngs::{self},
Rng, SeedableRng,
Expand Down Expand Up @@ -155,6 +156,16 @@ fn counter_add(c: &mut Criterion) {
});
}

criterion_group!(benches, criterion_benchmark);

criterion_main!(benches);
#[cfg(not(target_os = "windows"))]
criterion_group! {
name = benches;
config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = criterion_benchmark
}
#[cfg(target_os = "windows")]
criterion_group! {
name = benches;
config = Criterion::default();
targets = criterion_benchmark
}
criterion_main!(benches);

0 comments on commit 28fc70a

Please sign in to comment.