mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 04:01:51 +00:00
Add per-epoch benchmarks, optimise function.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use std::collections::HashSet;
|
||||
use fnv::FnvHashSet;
|
||||
use types::*;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Attesters {
|
||||
pub indices: HashSet<usize>,
|
||||
pub indices: FnvHashSet<usize>,
|
||||
pub balance: u64,
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ pub enum EpochProcessingError {
|
||||
NoBlockRoots,
|
||||
BaseRewardQuotientIsZero,
|
||||
NoRandaoSeed,
|
||||
PreviousTotalBalanceIsZero,
|
||||
InclusionDistanceZero,
|
||||
BeaconStateError(BeaconStateError),
|
||||
InclusionError(InclusionError),
|
||||
}
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
#![cfg(test)]
|
||||
use crate::per_epoch_processing;
|
||||
use benching_utils::BeaconStateBencher;
|
||||
use env_logger::{Builder, Env};
|
||||
use types::beacon_state::BeaconStateBuilder;
|
||||
use types::*;
|
||||
|
||||
#[test]
|
||||
fn runs_without_error() {
|
||||
Builder::from_env(Env::default().default_filter_or("error")).init();
|
||||
|
||||
let mut builder = BeaconStateBuilder::new(8);
|
||||
builder.spec = ChainSpec::few_validators();
|
||||
let spec = ChainSpec::few_validators();
|
||||
|
||||
builder.build().unwrap();
|
||||
builder.teleport_to_end_of_epoch(builder.spec.genesis_epoch + 4);
|
||||
let mut builder = BeaconStateBencher::new(8, &spec);
|
||||
builder.teleport_to_end_of_epoch(spec.genesis_epoch + 4, &spec);
|
||||
let mut state = builder.build();
|
||||
|
||||
let mut state = builder.cloned_state();
|
||||
|
||||
let spec = &builder.spec;
|
||||
per_epoch_processing(&mut state, spec).unwrap();
|
||||
per_epoch_processing(&mut state, &spec).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user