Add database type for import benchmarks (#5959)

* add database type for impot benchmarks

* add backend to name
This commit is contained in:
Nikolay Volf
2020-05-10 14:23:50 +03:00
committed by GitHub
parent c298b61375
commit 08302bc556
3 changed files with 75 additions and 21 deletions
+10 -2
View File
@@ -30,7 +30,7 @@
use std::borrow::Cow;
use node_testing::bench::{BenchDb, Profile, BlockType, KeyTypes};
use node_testing::bench::{BenchDb, Profile, BlockType, KeyTypes, DatabaseType};
use node_primitives::Block;
use sc_client_api::backend::Backend;
use sp_runtime::generic::BlockId;
@@ -72,6 +72,7 @@ pub struct ImportBenchmarkDescription {
pub key_types: KeyTypes,
pub block_type: BlockType,
pub size: SizeType,
pub database_type: DatabaseType,
}
pub struct ImportBenchmark {
@@ -101,6 +102,11 @@ impl core::BenchmarkDescription for ImportBenchmarkDescription {
BlockType::Noop(_) => path.push("noop"),
}
match self.database_type {
DatabaseType::RocksDb => path.push("rocksdb"),
DatabaseType::ParityDb => path.push("paritydb"),
}
path.push(&format!("{}", self.size));
path
@@ -109,6 +115,7 @@ impl core::BenchmarkDescription for ImportBenchmarkDescription {
fn setup(self: Box<Self>) -> Box<dyn core::Benchmark> {
let profile = self.profile;
let mut bench_db = BenchDb::with_key_types(
self.database_type,
50_000,
self.key_types
);
@@ -122,9 +129,10 @@ impl core::BenchmarkDescription for ImportBenchmarkDescription {
fn name(&self) -> Cow<'static, str> {
format!(
"Import benchmark ({:?}, {:?})",
"Import benchmark ({:?}, {:?}, {:?} backend)",
self.block_type,
self.profile,
self.database_type,
).into()
}
}
+14 -5
View File
@@ -26,7 +26,7 @@ use crate::core::{run_benchmark, Mode as BenchmarkMode};
use crate::tempdb::DatabaseType;
use import::{ImportBenchmarkDescription, SizeType};
use trie::{TrieReadBenchmarkDescription, TrieWriteBenchmarkDescription, DatabaseSize};
use node_testing::bench::{Profile, KeyTypes, BlockType};
use node_testing::bench::{Profile, KeyTypes, BlockType, DatabaseType as BenchDataBaseType};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
@@ -90,18 +90,21 @@ fn main() {
BlockType::RandomTransfersReaping(txs),
BlockType::Noop(txs),
].iter() {
import_benchmarks.push((profile.clone(), size.clone(), block_type.clone()));
for database_type in [BenchDataBaseType::RocksDb, BenchDataBaseType::ParityDb].iter() {
import_benchmarks.push((profile, size, block_type.clone(), database_type));
}
}
}
}
let benchmarks = matrix!(
(profile, size, block_type) in import_benchmarks.iter() =>
(profile, size, block_type, database_type) in import_benchmarks.into_iter() =>
ImportBenchmarkDescription {
profile: *profile,
key_types: KeyTypes::Sr25519,
size: *size,
block_type: *block_type,
block_type: block_type,
database_type: *database_type,
},
(size, db_type) in
[
@@ -128,8 +131,14 @@ fn main() {
);
if opt.list {
println!("Available benchmarks:");
if let Some(filter) = opt.filter.as_ref() {
println!("\t(filtered by \"{}\")", filter);
}
for benchmark in benchmarks.iter() {
log::info!("{}: {}", benchmark.name(), benchmark.path().full())
if opt.filter.as_ref().map(|f| benchmark.path().has(f)).unwrap_or(true) {
println!("{}: {}", benchmark.name(), benchmark.path().full())
}
}
return;
}