2019-04-28 01:38:32 +00:00
|
|
|
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();
|
2019-04-28 01:38:32 +00:00
|
|
|
|
|
|
|
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 {
|
2019-04-28 01:38:32 +00:00
|
|
|
run(&vec, &modified_vec);
|
|
|
|
}
|
|
|
|
}
|