Skip to content

Commit 2e02b09

Browse files
red15Niels Huylebroeck
andauthored
Fixed test-support/trie-bench test warning (#145)
* Fixed test-support/trie-bench test warning * rustfmt diff applied Co-authored-by: Niels Huylebroeck <[email protected]>
1 parent ee06b17 commit 2e02b09

File tree

1 file changed

+22
-11
lines changed
  • test-support/trie-bench/src

1 file changed

+22
-11
lines changed

test-support/trie-bench/src/lib.rs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
//! Standard trie benchmarking tool.
1616
17-
use criterion::{black_box, Criterion, Fun};
17+
use criterion::{black_box, BenchmarkId, Criterion};
1818
use hash_db::Hasher;
1919
use keccak_hasher::KeccakHasher;
2020
use memory_db::{HashKey, MemoryDB};
@@ -44,11 +44,20 @@ fn benchmark<L: TrieLayout, S: TrieStream>(
4444
) where
4545
<L::Hash as Hasher>::Out: 'static,
4646
{
47-
let funs = vec![
48-
Fun::new("Closed", |b, d: &TrieInsertionList| {
47+
let bench_size = content.len();
48+
let bench_list = &TrieInsertionList(content);
49+
let mut g = b.benchmark_group(name);
50+
g.bench_with_input(
51+
BenchmarkId::new("Closed", bench_size),
52+
bench_list,
53+
|b, d: &TrieInsertionList| {
4954
b.iter(&mut || trie_root::<L::Hash, S, _, _, _>(d.0.clone(), Default::default()))
50-
}),
51-
Fun::new("Fill", |b, d: &TrieInsertionList| {
55+
},
56+
);
57+
g.bench_with_input(
58+
BenchmarkId::new("Fill", bench_size),
59+
bench_list,
60+
|b, d: &TrieInsertionList| {
5261
b.iter(&mut || {
5362
let mut memdb = MemoryDB::<_, HashKey<L::Hash>, _>::new(L::Codec::empty_node());
5463
let mut root = <TrieHash<L>>::default();
@@ -57,8 +66,12 @@ fn benchmark<L: TrieLayout, S: TrieStream>(
5766
t.insert(&i.0, &i.1).unwrap();
5867
}
5968
})
60-
}),
61-
Fun::new("Iter", |b, d: &TrieInsertionList| {
69+
},
70+
);
71+
g.bench_with_input(
72+
BenchmarkId::new("Iter", bench_size),
73+
bench_list,
74+
|b, d: &TrieInsertionList| {
6275
let mut memdb = MemoryDB::<_, HashKey<_>, _>::new(L::Codec::empty_node());
6376
let mut root = <TrieHash<L>>::default();
6477
{
@@ -73,10 +86,8 @@ fn benchmark<L: TrieLayout, S: TrieStream>(
7386
black_box(n).unwrap();
7487
}
7588
})
76-
}),
77-
];
78-
79-
b.bench_functions(name, funs, TrieInsertionList(content));
89+
},
90+
);
8091
}
8192

8293
fn random_word(

0 commit comments

Comments
 (0)