diff options
| author | Santo Cariotti <santo@dcariotti.me> | 2025-06-23 07:54:32 +0000 |
|---|---|---|
| committer | Santo Cariotti <santo@dcariotti.me> | 2025-06-23 07:54:32 +0000 |
| commit | 9ec408203a1a13d2b8e450f7601b994070f0c91d (patch) | |
| tree | b51dc940fa549c6cfd5b02f1e11c1af5f9488463 /benches/bigfile.rs | |
| parent | be8ec280a056be688913c1a35c589ef406f72f50 (diff) | |
Add `Blake3Hasher`
Diffstat (limited to 'benches/bigfile.rs')
| -rw-r--r-- | benches/bigfile.rs | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/benches/bigfile.rs b/benches/bigfile.rs index 4a092e3..b2b013d 100644 --- a/benches/bigfile.rs +++ b/benches/bigfile.rs @@ -1,6 +1,6 @@ use criterion::{Criterion, criterion_group, criterion_main}; use mt_rs::{ - hasher::{Hasher, Keccak512Hasher, SHA256Hasher}, + hasher::{Blake3Hasher, Hasher, Keccak256Hasher, SHA256Hasher}, merkletree::MerkleTree, proof::{DefaultProofer, Proofer}, }; @@ -79,14 +79,26 @@ fn bench_large_merkle_tree_sha256(c: &mut Criterion) { cleanup_files(&filenames).expect("failed to deallocate data"); }, ); + } + group.finish(); +} + +/// Example of a MarkleTree with 10 nodes which use Keccak256 algorithm to make hashes. +/// Each node has a size of 5, 10 or 15 MB. +/// Also, it verifies each node path with a proofer O(n). +fn bench_large_merkle_tree_keccak256(c: &mut Criterion) { + let filenames: Vec<String> = (1..=10).map(|i| format!("file-{i}.dat")).collect(); + let mut group = c.benchmark_group("MerkleTree"); + group.sample_size(10); + for size in [5, 10, 15] { group.bench_function( - format!("MerkleTree creation and validation with 10 nodes and Keccak512 algorithm. {size} MB per each file."), + format!("MerkleTree creation and validation with 10 nodes and Keccak256 algorithm. {size} MB per each file."), |b| { let files = setup_files(&filenames, size).expect("failed to allocate new files"); b.iter(|| { - let hasher = Keccak512Hasher::new(); + let hasher = Keccak256Hasher::new(); test_merkle_tree(hasher, &files); }); cleanup_files(&filenames).expect("failed to deallocate data"); @@ -96,22 +108,22 @@ fn bench_large_merkle_tree_sha256(c: &mut Criterion) { group.finish(); } -/// Example of a MarkleTree with 10 nodes which use Keccak512 algorithm to make hashes. +/// Example of a MarkleTree with 10 nodes which use Blake3 algorithm to make hashes. /// Each node has a size of 5, 10 or 15 MB. /// Also, it verifies each node path with a proofer O(n). -fn bench_large_merkle_tree_keccak512(c: &mut Criterion) { +fn bench_large_merkle_tree_blake3(c: &mut Criterion) { let filenames: Vec<String> = (1..=10).map(|i| format!("file-{i}.dat")).collect(); let mut group = c.benchmark_group("MerkleTree"); group.sample_size(10); for size in [5, 10, 15] { group.bench_function( - format!("MerkleTree creation and validation with 10 nodes and Keccak512 algorithm. {size} MB per each file."), + format!("MerkleTree creation and validation with 10 nodes and Keccak256 algorithm. {size} MB per each file."), |b| { let files = setup_files(&filenames, size).expect("failed to allocate new files"); b.iter(|| { - let hasher = Keccak512Hasher::new(); + let hasher = Blake3Hasher::new(); test_merkle_tree(hasher, &files); }); cleanup_files(&filenames).expect("failed to deallocate data"); @@ -124,6 +136,7 @@ fn bench_large_merkle_tree_keccak512(c: &mut Criterion) { criterion_group!( benches, bench_large_merkle_tree_sha256, - bench_large_merkle_tree_keccak512 + bench_large_merkle_tree_keccak256, + bench_large_merkle_tree_blake3 ); criterion_main!(benches); |
