chore(bench): fix non deterministic bench IDs (#13530)

This commit is contained in:
DaniPopes
2024-12-24 00:39:54 +02:00
committed by GitHub
parent 5ea8f31896
commit 02ad280de6

View File

@ -61,21 +61,25 @@ pub fn prefix_set_lookups(c: &mut Criterion) {
&mut group, &mut group,
"`BTreeSet` with `Iterator:any` lookup", "`BTreeSet` with `Iterator:any` lookup",
test_data.clone(), test_data.clone(),
size,
); );
prefix_set_bench::<BTreeRangeLastCheckedPrefixSet>( prefix_set_bench::<BTreeRangeLastCheckedPrefixSet>(
&mut group, &mut group,
"`BTreeSet` with `BTreeSet:range` lookup", "`BTreeSet` with `BTreeSet:range` lookup",
test_data.clone(), test_data.clone(),
size,
); );
prefix_set_bench::<VecCursorPrefixSet>( prefix_set_bench::<VecCursorPrefixSet>(
&mut group, &mut group,
"`Vec` with custom cursor lookup", "`Vec` with custom cursor lookup",
test_data.clone(), test_data.clone(),
size,
); );
prefix_set_bench::<VecBinarySearchPrefixSet>( prefix_set_bench::<VecBinarySearchPrefixSet>(
&mut group, &mut group,
"`Vec` with binary search lookup", "`Vec` with binary search lookup",
test_data.clone(), test_data.clone(),
size,
); );
} }
} }
@ -84,6 +88,7 @@ fn prefix_set_bench<T>(
group: &mut BenchmarkGroup<'_, WallTime>, group: &mut BenchmarkGroup<'_, WallTime>,
description: &str, description: &str,
(preload, input, expected): (Vec<Nibbles>, Vec<Nibbles>, Vec<bool>), (preload, input, expected): (Vec<Nibbles>, Vec<Nibbles>, Vec<bool>),
size: usize,
) where ) where
T: PrefixSetMutAbstraction, T: PrefixSetMutAbstraction,
T::Frozen: PrefixSetAbstraction, T::Frozen: PrefixSetAbstraction,
@ -96,12 +101,7 @@ fn prefix_set_bench<T>(
(prefix_set.freeze(), input.clone(), expected.clone()) (prefix_set.freeze(), input.clone(), expected.clone())
}; };
let group_id = format!( let group_id = format!("prefix set | size: {size} | {description}");
"prefix set | preload size: {} | input size: {} | {}",
preload.len(),
input.len(),
description
);
group.bench_function(group_id, |b| { group.bench_function(group_id, |b| {
b.iter_with_setup(setup, |(mut prefix_set, input, expected)| { b.iter_with_setup(setup, |(mut prefix_set, input, expected)| {
for (idx, key) in input.into_iter().enumerate() { for (idx, key) in input.into_iter().enumerate() {
@ -120,12 +120,12 @@ fn generate_test_data(size: usize) -> (Vec<Nibbles>, Vec<Nibbles>, Vec<bool>) {
let vec_of_nibbles = |range| vec(any_with::<Nibbles>(range), size); let vec_of_nibbles = |range| vec(any_with::<Nibbles>(range), size);
let mut preload = vec_of_nibbles(32usize.into()).new_tree(&mut runner).unwrap().current(); let mut preload = vec_of_nibbles(32usize.into()).new_tree(&mut runner).unwrap().current();
preload.dedup();
preload.sort(); preload.sort();
preload.dedup();
let mut input = vec_of_nibbles((0..=32usize).into()).new_tree(&mut runner).unwrap().current(); let mut input = vec_of_nibbles((0..=32usize).into()).new_tree(&mut runner).unwrap().current();
input.dedup();
input.sort(); input.sort();
input.dedup();
let expected = input let expected = input
.iter() .iter()