diff --git a/eth2/state_processing/benches/benches.rs b/eth2/state_processing/benches/benches.rs index 52b939a69..239b782a3 100644 --- a/eth2/state_processing/benches/benches.rs +++ b/eth2/state_processing/benches/benches.rs @@ -5,7 +5,7 @@ mod epoch_processing_benches; criterion_group!( benches, - // epoch_processing_benches::epoch_processing_16k_validators, + epoch_processing_benches::epoch_processing_16k_validators, block_processing_benches::block_processing_16k_validators, ); criterion_main!(benches); diff --git a/eth2/state_processing/benches/block_processing_benches.rs b/eth2/state_processing/benches/block_processing_benches.rs index 755207f96..0b2968082 100644 --- a/eth2/state_processing/benches/block_processing_benches.rs +++ b/eth2/state_processing/benches/block_processing_benches.rs @@ -1,6 +1,7 @@ use benching_utils::{BeaconBlockBencher, BeaconStateBencher}; use criterion::Criterion; use criterion::{black_box, Benchmark}; +use ssz::TreeHash; use state_processing::{ per_block_processing, per_block_processing::{ @@ -400,4 +401,13 @@ fn bench_block_processing( }) .sample_size(10), ); + + let block = initial_block.clone(); + c.bench( + &format!("block_processing_{}", desc), + Benchmark::new("tree_hash_block", move |b| { + b.iter(|| black_box(block.hash_tree_root())) + }) + .sample_size(10), + ); } diff --git a/eth2/state_processing/benches/epoch_processing_benches.rs b/eth2/state_processing/benches/epoch_processing_benches.rs index 19c76fe36..8172ba99a 100644 --- a/eth2/state_processing/benches/epoch_processing_benches.rs +++ b/eth2/state_processing/benches/epoch_processing_benches.rs @@ -1,6 +1,7 @@ use benching_utils::BeaconStateBencher; use criterion::Criterion; use criterion::{black_box, Benchmark}; +use ssz::TreeHash; use state_processing::{ per_epoch_processing, per_epoch_processing::{ @@ -328,4 +329,16 @@ fn bench_epoch_processing(c: &mut Criterion, state: &BeaconState, spec: &ChainSp }) .sample_size(SMALL_BENCHING_SAMPLE_SIZE), ); + + let state_clone = state.clone(); + c.bench( + &format!("epoch_process_with_caches_{}", desc), + Benchmark::new("tree_hash_state", move |b| { + b.iter_with_setup( + || state_clone.clone(), + |state| black_box(state.hash_tree_root()), + ) + }) + .sample_size(SMALL_BENCHING_SAMPLE_SIZE), + ); }