Skip to content

Commit

Permalink
for benchmarking, enable reports and flamegraphs
Browse files Browse the repository at this point in the history
  • Loading branch information
shaun-cox authored and djc committed Jun 5, 2023
1 parent 800b9e3 commit 9cb677b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ members = [
"stress",
]
exclude = ["examples/external-otlp-grpcio-async-std"]

[profile.bench]
# https://doc.rust-lang.org/cargo/reference/profiles.html#bench
# See function names in profiling reports.
# 2/true is too much, 0 is not enough, 1 is just right for back traces
debug = 1
3 changes: 2 additions & 1 deletion opentelemetry-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ rustdoc-args = ["--cfg", "docsrs"]

[dev-dependencies]
bincode = "1.2"
criterion = "0.4.0"
criterion = { version = "0.4.0", features = ["html_reports"] }
pprof = { version = "0.11.1", features = ["flamegraph", "criterion"] }
rand_distr = "0.4.0"
crossbeam-queue = "0.3.1"

Expand Down
7 changes: 6 additions & 1 deletion opentelemetry-sdk/benches/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use opentelemetry_sdk::{
export::trace::{ExportResult, SpanData, SpanExporter},
trace as sdktrace,
};
use pprof::criterion::{Output, PProfProfiler};

fn criterion_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("EvictedHashMap");
Expand Down Expand Up @@ -132,5 +133,9 @@ fn trace_benchmark_group<F: Fn(&sdktrace::Tracer)>(c: &mut Criterion, name: &str
group.finish();
}

criterion_group!(benches, criterion_benchmark);
criterion_group! {
name = benches;
config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = criterion_benchmark
}
criterion_main!(benches);

0 comments on commit 9cb677b

Please sign in to comment.