mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(deps): bump nybbles, correct some unchecked usages (#6794)
Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
This commit is contained in:
@ -25,7 +25,7 @@ alloy-primitives = { workspace = true, features = ["rand", "rlp"] }
|
||||
alloy-rlp = { workspace = true, features = ["arrayvec"] }
|
||||
alloy-trie = { workspace = true, features = ["serde"] }
|
||||
ethers-core = { workspace = true, default-features = false, optional = true }
|
||||
nybbles = { version = "0.1.2", features = ["serde", "rlp"] }
|
||||
nybbles = { workspace = true, features = ["serde", "rlp"] }
|
||||
alloy-genesis.workspace = true
|
||||
alloy-eips.workspace = true
|
||||
# crypto
|
||||
@ -125,7 +125,3 @@ harness = false
|
||||
name = "trie_root"
|
||||
required-features = ["arbitrary", "test-utils"]
|
||||
harness = false
|
||||
|
||||
[[bench]]
|
||||
name = "nibbles"
|
||||
harness = false
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
#![allow(missing_docs)]
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use proptest::{prelude::*, strategy::ValueTree};
|
||||
use reth_primitives::trie::Nibbles;
|
||||
use std::{hint::black_box, time::Duration};
|
||||
|
||||
/// Benchmarks the nibble unpacking.
|
||||
pub fn nibbles_benchmark(c: &mut Criterion) {
|
||||
let mut g = c.benchmark_group("nibbles");
|
||||
g.warm_up_time(Duration::from_secs(1));
|
||||
g.noise_threshold(0.02);
|
||||
|
||||
g.bench_function("unpack/32", |b| {
|
||||
let bytes = get_bytes(32);
|
||||
b.iter(|| Nibbles::unpack(black_box(&bytes[..])))
|
||||
});
|
||||
g.bench_function("unpack/256", |b| {
|
||||
let bytes = get_bytes(256);
|
||||
b.iter(|| Nibbles::unpack(black_box(&bytes[..])))
|
||||
});
|
||||
g.bench_function("unpack/2048", |b| {
|
||||
let bytes = get_bytes(2048);
|
||||
b.iter(|| Nibbles::unpack(black_box(&bytes[..])))
|
||||
});
|
||||
|
||||
g.bench_function("pack/32", |b| {
|
||||
let nibbles = get_nibbles(32);
|
||||
b.iter(|| black_box(&nibbles).pack())
|
||||
});
|
||||
g.bench_function("pack/256", |b| {
|
||||
let nibbles = get_nibbles(256);
|
||||
b.iter(|| black_box(&nibbles).pack())
|
||||
});
|
||||
g.bench_function("pack/2048", |b| {
|
||||
let nibbles = get_nibbles(2048);
|
||||
b.iter(|| black_box(&nibbles).pack())
|
||||
});
|
||||
|
||||
g.bench_function("encode_path_leaf/31", |b| {
|
||||
let nibbles = get_nibbles(31);
|
||||
b.iter(|| black_box(&nibbles).encode_path_leaf(false))
|
||||
});
|
||||
g.bench_function("encode_path_leaf/256", |b| {
|
||||
let nibbles = get_nibbles(256);
|
||||
b.iter(|| black_box(&nibbles).encode_path_leaf(false))
|
||||
});
|
||||
g.bench_function("encode_path_leaf/2048", |b| {
|
||||
let nibbles = get_nibbles(2048);
|
||||
b.iter(|| black_box(&nibbles).encode_path_leaf(false))
|
||||
});
|
||||
}
|
||||
|
||||
fn get_nibbles(len: usize) -> Nibbles {
|
||||
Nibbles::from_nibbles_unchecked(get_bytes(len))
|
||||
}
|
||||
|
||||
fn get_bytes(len: usize) -> Vec<u8> {
|
||||
proptest::collection::vec(proptest::arbitrary::any::<u8>(), len)
|
||||
.new_tree(&mut Default::default())
|
||||
.unwrap()
|
||||
.current()
|
||||
}
|
||||
|
||||
criterion_group!(benches, nibbles_benchmark);
|
||||
criterion_main!(benches);
|
||||
Reference in New Issue
Block a user