diff --git a/test-support/trie-bench/src/lib.rs b/test-support/trie-bench/src/lib.rs index 1c8f5f16..65e0dd15 100644 --- a/test-support/trie-bench/src/lib.rs +++ b/test-support/trie-bench/src/lib.rs @@ -14,7 +14,7 @@ //! Standard trie benchmarking tool. -use criterion::{black_box, Criterion, Fun}; +use criterion::{black_box, BenchmarkId, Criterion}; use hash_db::Hasher; use keccak_hasher::KeccakHasher; use memory_db::{HashKey, MemoryDB}; @@ -44,11 +44,20 @@ fn benchmark( ) where ::Out: 'static, { - let funs = vec![ - Fun::new("Closed", |b, d: &TrieInsertionList| { + let bench_size = content.len(); + let bench_list = &TrieInsertionList(content); + let mut g = b.benchmark_group(name); + g.bench_with_input( + BenchmarkId::new("Closed", bench_size), + bench_list, + |b, d: &TrieInsertionList| { b.iter(&mut || trie_root::(d.0.clone(), Default::default())) - }), - Fun::new("Fill", |b, d: &TrieInsertionList| { + }, + ); + g.bench_with_input( + BenchmarkId::new("Fill", bench_size), + bench_list, + |b, d: &TrieInsertionList| { b.iter(&mut || { let mut memdb = MemoryDB::<_, HashKey, _>::new(L::Codec::empty_node()); let mut root = >::default(); @@ -57,8 +66,12 @@ fn benchmark( t.insert(&i.0, &i.1).unwrap(); } }) - }), - Fun::new("Iter", |b, d: &TrieInsertionList| { + }, + ); + g.bench_with_input( + BenchmarkId::new("Iter", bench_size), + bench_list, + |b, d: &TrieInsertionList| { let mut memdb = MemoryDB::<_, HashKey<_>, _>::new(L::Codec::empty_node()); let mut root = >::default(); { @@ -73,10 +86,8 @@ fn benchmark( black_box(n).unwrap(); } }) - }), - ]; - - b.bench_functions(name, funs, TrieInsertionList(content)); + }, + ); } fn random_word(