mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-30 01:28:21 -05:00
* database tx traits * wip build passes * Db and tx results * nightly and db GAT * Impl tx, wip cursor * Move Decode to Table Key, working cursor trait * wip dupsort * build all Cursor abstraction * cleanup * wip cleanup * old stages * codecs moved o interface,stages wip * resolve db ref, it builds * Add tx commit after execution * fmt * Remove sync send restriction * Add missing rw cursor functions * Cleanup, added missing cursor fn. rust toolchain * fmt * add nightly to ci * deny dead_code, remove unwrap * rm printfn, stages fix, bench fix
34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
|
|
|
/// Benchmarks the encoding and decoding of `Header` using criterion.
|
|
macro_rules! impl_criterion_encoding_benchmark {
|
|
($name:tt) => {
|
|
pub fn criterion_benchmark(c: &mut Criterion) {
|
|
let mut size = 0;
|
|
c.bench_function(stringify!($name), |b| {
|
|
b.iter(|| {
|
|
let encoded_size =
|
|
reth_interfaces::db::codecs::fuzz::Header::encode_and_decode(black_box(
|
|
reth_primitives::Header::default(),
|
|
))
|
|
.0;
|
|
|
|
if size == 0 {
|
|
size = encoded_size;
|
|
}
|
|
})
|
|
});
|
|
println!("Size (bytes): `{size}`");
|
|
}
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
|
criterion_main!(benches);
|
|
};
|
|
}
|
|
|
|
#[cfg(not(feature = "bench-postcard"))]
|
|
impl_criterion_encoding_benchmark!(scale);
|
|
|
|
#[cfg(feature = "bench-postcard")]
|
|
impl_criterion_encoding_benchmark!(postcard);
|