diff --git a/eth2/state_processing/Cargo.toml b/eth2/state_processing/Cargo.toml index 65d5a2f30..633c5bfef 100644 --- a/eth2/state_processing/Cargo.toml +++ b/eth2/state_processing/Cargo.toml @@ -15,6 +15,7 @@ serde = "1.0" serde_derive = "1.0" lazy_static = "0.1" serde_yaml = "0.8" +eth2_ssz = { path = "../utils/ssz" } beacon_chain = { path = "../../beacon_node/beacon_chain" } store = { path = "../../beacon_node/store" } lmd_ghost = { path = "../lmd_ghost" } diff --git a/eth2/state_processing/benches/benches.rs b/eth2/state_processing/benches/benches.rs index 28afd0614..bdbe57b8e 100644 --- a/eth2/state_processing/benches/benches.rs +++ b/eth2/state_processing/benches/benches.rs @@ -2,6 +2,7 @@ extern crate env_logger; use criterion::Criterion; use criterion::{black_box, criterion_group, criterion_main, Benchmark}; +use ssz::Encode; use state_processing::{test_utils::BlockBuilder, BlockSignatureStrategy, VerifySignatures}; use types::{BeaconBlock, BeaconState, ChainSpec, EthSpec, MainnetEthSpec, MinimalEthSpec, Slot}; @@ -393,6 +394,32 @@ fn bench_block( }) .sample_size(10), ); + + let local_block = block.clone(); + c.bench( + &title, + Benchmark::new("ssz_serialize_block", move |b| { + b.iter_batched_ref( + || (), + |_| black_box(local_block.as_ssz_bytes()), + criterion::BatchSize::SmallInput, + ) + }) + .sample_size(10), + ); + + let local_block = block.clone(); + c.bench( + &title, + Benchmark::new("ssz_block_len", move |b| { + b.iter_batched_ref( + || (), + |_| black_box(local_block.ssz_bytes_len()), + criterion::BatchSize::SmallInput, + ) + }) + .sample_size(10), + ); } criterion_group!(benches, all_benches,);