diff --git a/benches/inspect.rs b/benches/inspect.rs index 7450cad7d..4e64d8723 100644 --- a/benches/inspect.rs +++ b/benches/inspect.rs @@ -7,6 +7,8 @@ use blazesym::inspect::Inspector; use criterion::measurement::Measurement; use criterion::BenchmarkGroup; +use crate::bench_fn_name; + /// Lookup an address in a DWARF file, end-to-end, i.e., including all necessary /// setup. @@ -34,6 +36,8 @@ where M: Measurement, { if cfg!(feature = "generate-large-test-files") { - group.bench_function(stringify!(inspect::lookup_dwarf), |b| b.iter(lookup_dwarf)); + group.bench_function(bench_fn_name(stringify!(inspect::lookup_dwarf)), |b| { + b.iter(lookup_dwarf) + }); } } diff --git a/benches/main.rs b/benches/main.rs index 6de10e287..6340aa32c 100644 --- a/benches/main.rs +++ b/benches/main.rs @@ -10,6 +10,12 @@ use criterion::criterion_group; use criterion::criterion_main; use criterion::Criterion; +const BENCH_NAME_WIDTH: usize = 42; + +pub(crate) fn bench_fn_name(name: &str) -> String { + format!("{name:(group: &mut BenchmarkGroup<'_, M>) where M: Measurement, { - group.bench_function(stringify!(normalize::normalize_process), |b| { - b.iter(normalize_process) - }); + group.bench_function( + bench_fn_name(stringify!(normalize::normalize_process)), + |b| b.iter(normalize_process), + ); } diff --git a/benches/symbolize.rs b/benches/symbolize.rs index 0f812b473..7b0d7a8c3 100644 --- a/benches/symbolize.rs +++ b/benches/symbolize.rs @@ -13,6 +13,8 @@ use blazesym::Pid; use criterion::measurement::Measurement; use criterion::BenchmarkGroup; +use crate::bench_fn_name; + /// Symbolize addresses in the current process. fn symbolize_process() { @@ -78,14 +80,15 @@ pub fn benchmark(group: &mut BenchmarkGroup<'_, M>) where M: Measurement, { - group.bench_function(stringify!(symbolize::symbolize_process), |b| { - b.iter(symbolize_process) - }); + group.bench_function( + bench_fn_name(stringify!(symbolize::symbolize_process)), + |b| b.iter(symbolize_process), + ); if cfg!(feature = "generate-large-test-files") { - group.bench_function(stringify!(symbolize::symbolize_dwarf), |b| { + group.bench_function(bench_fn_name(stringify!(symbolize::symbolize_dwarf)), |b| { b.iter(symbolize_dwarf) }); - group.bench_function(stringify!(symbolize::symbolize_gsym), |b| { + group.bench_function(bench_fn_name(stringify!(symbolize::symbolize_gsym)), |b| { b.iter(symbolize_gsym) }); }