Update epoch trans. tests to us 16,384 validators

This commit is contained in:
Paul Hauner 2019-02-26 22:25:29 +13:00
parent af17fb1d03
commit 3ff8f6ebb3
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C

View File

@ -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,);