perf(trie): prealloc in Nibble::unpack (#5629)

This commit is contained in:
Vitaly Drogan
2023-11-29 22:22:04 +01:00
committed by GitHub
parent 471c28e889
commit e9dfd059dd
3 changed files with 28 additions and 7 deletions

View File

@ -0,0 +1,19 @@
use criterion::{criterion_group, criterion_main, Criterion};
use reth_primitives::trie::Nibbles;
/// Benchmarks the nibble unpacking.
pub fn nibbles_benchmark(c: &mut Criterion) {
c.bench_function("Nibbles unpack", |b| {
let raw = (1..=32).collect::<Vec<u8>>();
b.iter(|| {
Nibbles::unpack(&raw);
})
});
}
criterion_group! {
name = benches;
config = Criterion::default();
targets = nibbles_benchmark
}
criterion_main!(benches);