chore: add pprof profiler/flamegraphs to all criterion benchmarks (#1425)

This commit is contained in:
joshieDo
2023-02-17 17:08:32 +08:00
committed by GitHub
parent fad9c04b07
commit 495db6e30d
11 changed files with 43 additions and 6 deletions

View File

@ -24,6 +24,7 @@ ffi = { package = "reth-mdbx-sys", path = "./mdbx-sys" }
lifetimed-bytes = { version = "0.1", optional = true }
[dev-dependencies]
pprof = { version = "0.11", features = ["flamegraph", "frame-pointer", "criterion"] }
criterion = "0.4"
rand = "0.8"
rand_xorshift = "0.3"

View File

@ -2,6 +2,7 @@ mod utils;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use ffi::*;
use pprof::criterion::{Output, PProfProfiler};
use reth_libmdbx::*;
use std::ptr;
use utils::*;
@ -101,5 +102,9 @@ fn bench_get_seq_raw(c: &mut Criterion) {
});
}
criterion_group!(benches, bench_get_seq_iter, bench_get_seq_cursor, bench_get_seq_raw);
criterion_group! {
name = benches;
config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = bench_get_seq_iter, bench_get_seq_cursor, bench_get_seq_raw
}
criterion_main!(benches);

View File

@ -115,5 +115,9 @@ fn bench_put_rand_raw(c: &mut Criterion) {
});
}
criterion_group!(benches, bench_get_rand, bench_get_rand_raw, bench_put_rand, bench_put_rand_raw);
criterion_group! {
name = benches;
config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = bench_get_rand, bench_get_rand_raw, bench_put_rand, bench_put_rand_raw
}
criterion_main!(benches);