Skip to content

Commit

Permalink
Add parallel tree hashing benchmark (#28)
Browse files Browse the repository at this point in the history
* Add parallel bench

* Clone second list

* Use two threads
  • Loading branch information
macladson authored Sep 5, 2023
1 parent c7ff980 commit 40a5364
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions benches/tree_hash_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ pub fn tree_hash_root(c: &mut Criterion) {
})
},
);

c.bench_with_input(
BenchmarkId::new("tree_hash_root_list_parallel", size),
&size,
|b, &size| {
b.iter(|| {
let l1 = List::<u64, C>::try_from_iter(0..size).unwrap();
let mut l2 = l1.clone();
l2.push(99).unwrap();
l2.apply_updates().unwrap();

let handle_1 = std::thread::spawn(move || {
l1.tree_hash_root();
});
let handle_2 = std::thread::spawn(move || {
l2.tree_hash_root();
});

handle_1.join().unwrap();
handle_2.join().unwrap();
});
},
);
}

criterion_group!(benches, tree_hash_root);
Expand Down

0 comments on commit 40a5364

Please sign in to comment.