diff --git a/eth2/state_processing/benches/benches.rs b/eth2/state_processing/benches/benches.rs index 244e3c8a5..682259eef 100644 --- a/eth2/state_processing/benches/benches.rs +++ b/eth2/state_processing/benches/benches.rs @@ -1,5 +1,5 @@ use criterion::Criterion; -use criterion::{black_box, criterion_group, criterion_main}; +use criterion::{black_box, criterion_group, criterion_main, Benchmark}; // use env_logger::{Builder, Env}; use state_processing::SlotProcessable; use types::beacon_state::BeaconStateBuilder; @@ -8,10 +8,9 @@ use types::*; fn epoch_processing(c: &mut Criterion) { // Builder::from_env(Env::default().default_filter_or("debug")).init(); - let mut builder = BeaconStateBuilder::new(8); - builder.spec = ChainSpec::few_validators(); + let mut builder = BeaconStateBuilder::new(16_384); - builder.build().unwrap(); + builder.build_fast().unwrap(); builder.teleport_to_end_of_epoch(builder.spec.genesis_epoch + 4); let mut state = builder.cloned_state(); @@ -39,19 +38,27 @@ fn epoch_processing(c: &mut Criterion) { let spec_a = builder.spec.clone(); let spec_b = builder.spec.clone(); - c.bench_function("epoch processing with pre-built caches", move |b| { - b.iter_with_setup( - || cached_state.clone(), - |mut state| black_box(state.per_slot_processing(Hash256::zero(), &spec_a).unwrap()), - ) - }); + c.bench( + "epoch processing", + Benchmark::new("with pre-built caches", move |b| { + b.iter_with_setup( + || cached_state.clone(), + |mut state| black_box(state.per_slot_processing(Hash256::zero(), &spec_a).unwrap()), + ) + }) + .sample_size(10), + ); - c.bench_function("epoch processing without pre-built caches", move |b| { - b.iter_with_setup( - || cacheless_state.clone(), - |mut state| black_box(state.per_slot_processing(Hash256::zero(), &spec_b).unwrap()), - ) - }); + c.bench( + "epoch processing", + Benchmark::new("without pre-built caches", move |b| { + b.iter_with_setup( + || cacheless_state.clone(), + |mut state| black_box(state.per_slot_processing(Hash256::zero(), &spec_b).unwrap()), + ) + }) + .sample_size(10), + ); } criterion_group!(benches, epoch_processing,);