Skip to content

Commit 7b5edd6

Browse files
authored
Merge pull request metrico#590 from metrico/refactor/pprof
pprof module refactor
2 parents 4dcd757 + e76ef87 commit 7b5edd6

File tree

5 files changed

+2287
-571
lines changed

5 files changed

+2287
-571
lines changed

pyroscope/pprof-bin/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@ flate2 = "1.0"
2727
# code size when deploying.
2828
console_error_panic_hook = { version = "0.1.7", optional = true }
2929
base64 = "0.22.1"
30+
memchr = "2.7.4"
3031

3132
[dev-dependencies]
3233
wasm-bindgen-test = "0.3.34"
34+
criterion = { version = "0.5.1", features = ["html_reports"] }
35+
36+
[[bench]]
37+
name = "my_benchmark"
38+
harness = false
3339

3440
[profile.release]
3541
# Tell `rustc` to optimize for small code size.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use pprof_bin::merge_prof;
2+
use pprof_bin::utest::get_test_pprof_data;
3+
use criterion::{black_box, criterion_group, criterion_main, Criterion};
4+
5+
fn merge_bench(pprofs: &Vec<Vec<u8>>) {
6+
7+
for pprof in pprofs {
8+
merge_prof(0, pprof.as_slice(), "process_cpu:samples:count:cpu:nanoseconds".to_string());
9+
}
10+
}
11+
12+
fn criterion_benchmark(c: &mut Criterion) {
13+
let pprofs = get_test_pprof_data();
14+
c.bench_function("merge", |b| b.iter(|| merge_bench(&pprofs)));
15+
}
16+
17+
criterion_group!(benches, criterion_benchmark);
18+
criterion_main!(benches);
-8.83 KB
Binary file not shown.

0 commit comments

Comments
 (0)