lighthouse/eth2/utils/cached_tree_hash/examples/8k_hashes_cached.rs

22 lines
490 B
Rust
Raw Normal View History

use cached_tree_hash::TreeHashCache;
use ethereum_types::H256 as Hash256;
fn run(vec: &Vec<Hash256>, modified_vec: &Vec<Hash256>) {
2019-04-29 07:46:01 +00:00
let mut cache = TreeHashCache::new(vec).unwrap();
cache.update(modified_vec).unwrap();
}
fn main() {
let n = 2048;
let vec: Vec<Hash256> = (0..n).map(|_| Hash256::random()).collect();
let mut modified_vec = vec.clone();
modified_vec[n - 1] = Hash256::random();
2019-04-28 09:10:59 +00:00
for _ in 0..10_000 {
run(&vec, &modified_vec);
}
}