cli: introduce host-perf-check command (#4342)

This commit is contained in:
Chris Sosnin
2021-12-09 14:26:16 +03:00
committed by GitHub
parent 2982387131
commit 762ec19ac0
16 changed files with 417 additions and 17 deletions
+23 -14
View File
@@ -21,20 +21,8 @@ use sc_cli::{Role, RuntimeVersion, SubstrateCli};
use service::{self, IdentifyVariant};
use sp_core::crypto::Ss58AddressFormatRegistry;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error(transparent)]
PolkadotService(#[from] service::Error),
#[error(transparent)]
SubstrateCli(#[from] sc_cli::Error),
#[error(transparent)]
SubstrateService(#[from] sc_service::Error),
#[error("Other: {0}")]
Other(String),
}
pub use crate::error::Error;
pub use polkadot_performance_test::PerfCheckError;
impl std::convert::From<String> for Error {
fn from(s: String) -> Self {
@@ -215,6 +203,20 @@ fn ensure_dev(spec: &Box<dyn service::ChainSpec>) -> std::result::Result<(), Str
}
}
/// Runs performance checks.
/// Should only be used in release build since the check would take too much time otherwise.
fn host_perf_check() -> Result<()> {
#[cfg(not(build_type = "release"))]
{
Err(PerfCheckError::WrongBuildType.into())
}
#[cfg(build_type = "release")]
{
crate::host_perf_check::host_perf_check()?;
Ok(())
}
}
/// Launch a node, accepting arguments just like a regular node,
/// accepts an alternative overseer generator, to adjust behavior
/// for integration tests as needed.
@@ -415,6 +417,13 @@ pub fn run() -> Result<()> {
#[cfg(not(feature = "polkadot-native"))]
panic!("No runtime feature (polkadot, kusama, westend, rococo) is enabled")
},
Some(Subcommand::HostPerfCheck) => {
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_colors(true);
builder.init()?;
host_perf_check()
},
Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?),
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {