Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf-test filtering and add txpool test #966

Merged
merged 2 commits into from
Nov 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions node/perf-test/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,19 @@ impl PerfCmd {

let mut all_test_results: Vec<TestResults> = Default::default();

let (have_filter, enabled_tests) = if let Some(filter) = &cmd.tests {
let enabled_tests: Vec<&str> = filter.split(',').collect();
(true, enabled_tests)
} else {
(false, Default::default())
};

for mut test in tests {
if have_filter {
if !enabled_tests.contains(&test.name().as_str()) {
continue;
}
}
let mut results: Vec<TestResults> = (*test.run(&runner)?).to_vec();
all_test_results.append(&mut results);
}
Expand Down
7 changes: 7 additions & 0 deletions node/perf-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,11 @@ pub struct PerfCmd {
help = "File where results should be printed (STDOUT if omitted)."
)]
pub output_file: Option<PathBuf>,

// TODO: allow multiple tests (like the -l switch for logging)
#[structopt(
long = "tests",
help = "Comma-separated list of tests to run (if omitted, runs all tests)"
)]
pub tests: Option<String>,
}
4 changes: 4 additions & 0 deletions node/perf-test/src/tests/block_creation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ where
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
Executor: NativeExecutionDispatch + 'static,
{
fn name(&self) -> String {
"block_creation".into()
}

fn run(
&mut self,
context: &TestContext<RuntimeApi, Executor>,
Expand Down
4 changes: 4 additions & 0 deletions node/perf-test/src/tests/fibonacci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ where
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
Executor: NativeExecutionDispatch + 'static,
{
fn name(&self) -> String {
"fibonacci".into()
}

fn run(
&mut self,
context: &TestContext<RuntimeApi, Executor>,
Expand Down
5 changes: 5 additions & 0 deletions node/perf-test/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ where
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
Executor: NativeExecutionDispatch + 'static,
{
/// Return a globally unique name for this test. This is used as a filter on the command line
/// so a CLI-friendly name is preferred.
fn name(&self) -> String;

/// Run the test
fn run(
&mut self,
context: &TestContext<RuntimeApi, Executor>,
Expand Down
4 changes: 4 additions & 0 deletions node/perf-test/src/tests/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ where
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
Executor: NativeExecutionDispatch + 'static,
{
fn name(&self) -> String {
"storage".into()
}

fn run(
&mut self,
context: &TestContext<RuntimeApi, Executor>,
Expand Down