Skip to content

Commit

Permalink
change params
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Oct 25, 2024
1 parent 1f36684 commit b8399c5
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions crates/trie/sparse/benches/rlp_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,36 @@ pub fn update_rlp_node_level(c: &mut Criterion) {
}
sparse.root();

// Update 10% of the leaves, that will add them to the prefix set
for key in state.keys().choose_multiple(&mut rng, size / 10) {
sparse
.update_leaf(
Nibbles::unpack(key),
alloy_rlp::encode_fixed_size(&rng.gen::<U256>()).to_vec(),
)
.unwrap();
}
for updated_leaves in [0.1, 1.0, 10.0] {
for key in state
.keys()
.choose_multiple(&mut rng, (size as f64 * (updated_leaves / 100.0)) as usize)
{
sparse
.update_leaf(
Nibbles::unpack(key),
alloy_rlp::encode_fixed_size(&rng.gen::<U256>()).to_vec(),
)
.unwrap();
}

// Calculate the maximum depth of the trie for the given number of leaves
let max_depth = (size as f64).log(16.0).ceil() as usize;
// Calculate the maximum depth of the trie for the given number of leaves
let max_depth = (size as f64).log(16.0).ceil() as usize;

for depth in 0..=max_depth {
group.bench_function(format!("size {size} | depth {depth}"), |b| {
b.iter_with_setup(
|| sparse.clone(),
|mut sparse| sparse.update_rlp_node_level(depth),
)
});
for depth in 0..=max_depth {
group.bench_function(
format!("size {size} | updated {updated_leaves}% | depth {depth}"),
|b| {
b.iter_with_setup(
|| sparse.clone(),
|mut sparse| {
sparse.update_rlp_node_level(depth);
panic!();
},
)
},
);
}
}
}
}
Expand Down

0 comments on commit b8399c5

Please sign in to comment.