//! [`MerkleTree::from_iter`] Benchmark //! //! [`merkletree::from_iter`]: https://doc.rust-lang.org/nightly/core/iter/trait.FromIterator.html#tymethod.from_iter #[macro_use] extern crate bencher; use bencher::Bencher; use digest::generic_array::{ArrayLength, GenericArray}; use digest::{typenum, Digest, OutputSizeUser}; use merkle_lite::MerkleTree; const NR_LEAVES: usize = 100_000; benchmark_main!(sha2, sha3); // With [SHA2] hash functions. // // [sha2]: https://crates.io/crates/sha3 benchmark_group!( sha2, tree_from_iter::, tree_from_iter::, tree_from_iter::, tree_from_iter::, ); // With [SHA3] hash functions. // // [sha3]: https://crates.io/crates/sha3 benchmark_group!( sha3, tree_from_iter::, tree_from_iter::, tree_from_iter::, tree_from_iter::, ); fn tree_from_iter(b: &mut Bencher) where N: ArrayLength, B: Digest, >::ArrayType: Copy, <::OutputSize as ArrayLength>::ArrayType: Copy, { let leaves = vec![GenericArray::::default(); NR_LEAVES]; b.iter(|| { // compose the Merkle tree from the leaves. assert_eq!( MerkleTree::::from_iter(leaves.iter()).leaf_len(), NR_LEAVES ); }) }