mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
Add tests and benches for epoch processing
This commit is contained in:
28
eth2/state_processing/benches/benches.rs
Normal file
28
eth2/state_processing/benches/benches.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use criterion::Criterion;
|
||||
use criterion::{black_box, criterion_group, criterion_main};
|
||||
// use env_logger::{Builder, Env};
|
||||
use state_processing::SlotProcessable;
|
||||
use types::{beacon_state::BeaconStateBuilder, ChainSpec, Hash256};
|
||||
|
||||
fn epoch_processing(c: &mut Criterion) {
|
||||
// Builder::from_env(Env::default().default_filter_or("debug")).init();
|
||||
|
||||
let mut builder = BeaconStateBuilder::with_random_validators(8);
|
||||
builder.spec = ChainSpec::few_validators();
|
||||
|
||||
builder.genesis().unwrap();
|
||||
builder.teleport_to_end_of_epoch(builder.spec.genesis_epoch + 4);
|
||||
|
||||
let state = builder.build().unwrap();
|
||||
|
||||
c.bench_function("epoch processing", move |b| {
|
||||
let spec = &builder.spec;
|
||||
b.iter_with_setup(
|
||||
|| state.clone(),
|
||||
|mut state| black_box(state.per_slot_processing(Hash256::zero(), spec).unwrap()),
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
criterion_group!(benches, epoch_processing,);
|
||||
criterion_main!(benches);
|
||||
Reference in New Issue
Block a user