mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 06:27:58 +00:00
Speedup import benchmark (#4995)
* use lazy matrix * speedup * Update bin/node/testing/benches/import.rs Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -37,7 +37,7 @@ use sc_client_api::backend::Backend;
|
||||
|
||||
criterion_group!(
|
||||
name = benches;
|
||||
config = Criterion::default().sample_size(50).warm_up_time(std::time::Duration::from_secs(20));
|
||||
config = Criterion::default().sample_size(20).warm_up_time(std::time::Duration::from_secs(20));
|
||||
targets = bench_block_import
|
||||
);
|
||||
criterion_group!(
|
||||
@@ -50,7 +50,7 @@ criterion_group!(
|
||||
config = Criterion::default().sample_size(10);
|
||||
targets = profile_block_import
|
||||
);
|
||||
criterion_main!(benches, profile, wasm_size);
|
||||
criterion_main!(benches, profile);
|
||||
|
||||
fn bench_block_import(c: &mut Criterion) {
|
||||
sc_cli::init_logger("");
|
||||
@@ -152,6 +152,33 @@ struct Setup {
|
||||
block: Block,
|
||||
}
|
||||
|
||||
struct SetupIterator {
|
||||
current: usize,
|
||||
finish: usize,
|
||||
multiplier: usize,
|
||||
}
|
||||
|
||||
impl SetupIterator {
|
||||
fn new(current: usize, finish: usize, multiplier: usize) -> Self {
|
||||
SetupIterator { current, finish, multiplier }
|
||||
}
|
||||
}
|
||||
|
||||
impl Iterator for SetupIterator {
|
||||
type Item = Setup;
|
||||
|
||||
fn next(&mut self) -> Option<Setup> {
|
||||
if self.current >= self.finish { return None }
|
||||
|
||||
self.current += 1;
|
||||
|
||||
let size = self.current * self.multiplier;
|
||||
let mut db = BenchDb::new(size);
|
||||
let block = db.generate_block(size);
|
||||
Some(Setup { db, block })
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Setup {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "Setup: {} tx/block", self.block.extrinsics.len())
|
||||
@@ -161,14 +188,6 @@ impl fmt::Debug for Setup {
|
||||
fn bench_wasm_size_import(c: &mut Criterion) {
|
||||
sc_cli::init_logger("");
|
||||
|
||||
let mut setups = Vec::new();
|
||||
|
||||
for block_size in 5..15 {
|
||||
let mut db = BenchDb::new(block_size*50);
|
||||
let block = db.generate_block(block_size * 50);
|
||||
setups.push(Setup { db, block });
|
||||
}
|
||||
|
||||
c.bench_function_over_inputs("wasm_size_import",
|
||||
move |bencher, setup| {
|
||||
bencher.iter_batched(
|
||||
@@ -181,6 +200,6 @@ fn bench_wasm_size_import(c: &mut Criterion) {
|
||||
criterion::BatchSize::PerIteration,
|
||||
);
|
||||
},
|
||||
setups,
|
||||
SetupIterator::new(5, 15, 50),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user