summaryrefslogtreecommitdiffstats
path: root/benches/bigfile.rs
diff options
context:
space:
mode:
Diffstat (limited to 'benches/bigfile.rs')
-rw-r--r--benches/bigfile.rs29
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);