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
2 changed files with 28 additions and 0 deletions

View File

@@ -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<T: EthSpec>(
})
.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,);