Add ssz benches to state processing

This commit is contained in:
Paul Hauner 2019-09-08 13:42:38 -04:00
parent 834c36d602
commit 6311b13169
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
2 changed files with 28 additions and 0 deletions

View File

@ -15,6 +15,7 @@ serde = "1.0"
serde_derive = "1.0" serde_derive = "1.0"
lazy_static = "0.1" lazy_static = "0.1"
serde_yaml = "0.8" serde_yaml = "0.8"
eth2_ssz = { path = "../utils/ssz" }
beacon_chain = { path = "../../beacon_node/beacon_chain" } beacon_chain = { path = "../../beacon_node/beacon_chain" }
store = { path = "../../beacon_node/store" } store = { path = "../../beacon_node/store" }
lmd_ghost = { path = "../lmd_ghost" } lmd_ghost = { path = "../lmd_ghost" }

View File

@ -2,6 +2,7 @@ extern crate env_logger;
use criterion::Criterion; use criterion::Criterion;
use criterion::{black_box, criterion_group, criterion_main, Benchmark}; use criterion::{black_box, criterion_group, criterion_main, Benchmark};
use ssz::Encode;
use state_processing::{test_utils::BlockBuilder, BlockSignatureStrategy, VerifySignatures}; use state_processing::{test_utils::BlockBuilder, BlockSignatureStrategy, VerifySignatures};
use types::{BeaconBlock, BeaconState, ChainSpec, EthSpec, MainnetEthSpec, MinimalEthSpec, Slot}; use types::{BeaconBlock, BeaconState, ChainSpec, EthSpec, MainnetEthSpec, MinimalEthSpec, Slot};
@ -393,6 +394,32 @@ fn bench_block<T: EthSpec>(
}) })
.sample_size(10), .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,); criterion_group!(benches, all_benches,);