properly handle different block content (#6007)

This commit is contained in:
Nikolay Volf
2020-05-13 23:48:28 +03:00
committed by GitHub
parent 074d80f519
commit 91d93be9b5
3 changed files with 56 additions and 46 deletions
+12 -12
View File
@@ -50,19 +50,19 @@ pub enum SizeType {
#[display(fmt = "full")]
Full,
#[display(fmt = "custom")]
Custom,
Custom(usize),
}
impl SizeType {
pub fn transactions(&self) -> usize {
pub fn transactions(&self) -> Option<usize> {
match self {
SizeType::Empty => 0,
SizeType::Small => 10,
SizeType::Medium => 100,
SizeType::Large => 500,
SizeType::Full => 4000,
SizeType::Empty => Some(0),
SizeType::Small => Some(10),
SizeType::Medium => Some(100),
SizeType::Large => Some(500),
SizeType::Full => None,
// Custom SizeType will use the `--transactions` input parameter
SizeType::Custom => 0,
SizeType::Custom(val) => Some(*val),
}
}
}
@@ -97,9 +97,9 @@ impl core::BenchmarkDescription for ImportBenchmarkDescription {
}
match self.block_type {
BlockType::RandomTransfersKeepAlive(_) => path.push("transfer_keep_alive"),
BlockType::RandomTransfersReaping(_) => path.push("transfer_reaping"),
BlockType::Noop(_) => path.push("noop"),
BlockType::RandomTransfersKeepAlive => path.push("transfer_keep_alive"),
BlockType::RandomTransfersReaping => path.push("transfer_reaping"),
BlockType::Noop => path.push("noop"),
}
match self.database_type {
@@ -119,7 +119,7 @@ impl core::BenchmarkDescription for ImportBenchmarkDescription {
50_000,
self.key_types
);
let block = bench_db.generate_block(self.block_type);
let block = bench_db.generate_block(self.block_type.to_content(self.size.transactions()));
Box::new(ImportBenchmark {
database: bench_db,
block,
+6 -10
View File
@@ -79,19 +79,15 @@ fn main() {
SizeType::Medium,
SizeType::Large,
SizeType::Full,
SizeType::Custom,
SizeType::Custom(opt.transactions.unwrap_or(0)),
].iter() {
let txs = match size {
SizeType::Custom => opt.transactions.unwrap_or(0),
_ => size.transactions()
};
for block_type in [
BlockType::RandomTransfersKeepAlive(txs),
BlockType::RandomTransfersReaping(txs),
BlockType::Noop(txs),
BlockType::RandomTransfersKeepAlive,
BlockType::RandomTransfersReaping,
BlockType::Noop,
].iter() {
for database_type in [BenchDataBaseType::RocksDb, BenchDataBaseType::ParityDb].iter() {
import_benchmarks.push((profile, size, block_type.clone(), database_type));
import_benchmarks.push((profile, size.clone(), block_type.clone(), database_type));
}
}
}
@@ -102,7 +98,7 @@ fn main() {
ImportBenchmarkDescription {
profile: *profile,
key_types: KeyTypes::Sr25519,
size: *size,
size: size,
block_type: block_type,
database_type: *database_type,
},