mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +00:00
* Starting * closer * Compiles! * comments * Create seperate mock * Remove changes to test env * Fix step calculation * Add host function * Add runtime api * compiles * Update to use offchain timestamp * Gives a result * added some CLI wip * make generic * Update instance * Remove CLI stuff * Remove last cli stuff * undo more changes * Update benchmarks * Update Cargo.lock * remove test * Move loop out of runtime * Benchmarking externalities * Benchmarking state * Implemented commit * Make CLI work, move loop back into runtime * Wipe resets to genesis * Speedup benchmarks * Use enum to select extrinsic within pallet * CLI controls which module and extrinsic to call * Select a pallet with cli * Add steps and repeats to cli * Output as CSV format * Introduce benchmark pallet * Append bench * Use Results * fix merge * Clear Identity benchmark * Bench request judgment and cancel request * Add final benchmarks * Fix CSV output * Start cleaning up for PR * Bump numbers in `wasmtime` integration tests. * More docs * Add rockdb feature to bench * Fix formatting issues * Add test feature to bench * Add test feature to bench * Add rocksdb feature flag * Update bench.rs Co-authored-by: Arkadiy Paronyan <arkady.paronyan@gmail.com> Co-authored-by: Gavin Wood <github@gavwood.com>
This commit is contained in:
@@ -58,6 +58,7 @@ use params::{
|
||||
pub use params::{
|
||||
SharedParams, ImportParams, ExecutionStrategy, Subcommand, RunCmd, BuildSpecCmd,
|
||||
ExportBlocksCmd, ImportBlocksCmd, CheckBlockCmd, PurgeChainCmd, RevertCmd,
|
||||
BenchmarkCmd,
|
||||
};
|
||||
pub use traits::GetSharedParams;
|
||||
use app_dirs::{AppInfo, AppDataType};
|
||||
|
||||
@@ -845,6 +845,49 @@ pub struct PurgeChainCmd {
|
||||
pub shared_params: SharedParams,
|
||||
}
|
||||
|
||||
/// The `benchmark` command used to benchmark FRAME Pallets.
|
||||
#[derive(Debug, StructOpt, Clone)]
|
||||
pub struct BenchmarkCmd {
|
||||
/// Select a FRAME Pallet to benchmark.
|
||||
#[structopt(short, long)]
|
||||
pub pallet: String,
|
||||
|
||||
/// Select an extrinsic to benchmark.
|
||||
#[structopt(short, long)]
|
||||
pub extrinsic: String,
|
||||
|
||||
/// Select how many samples we should take across the variable components.
|
||||
#[structopt(short, long, default_value = "1")]
|
||||
pub steps: u32,
|
||||
|
||||
/// Select how many repetitions of this benchmark should run.
|
||||
#[structopt(short, long, default_value = "1")]
|
||||
pub repeat: u32,
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[structopt(flatten)]
|
||||
pub shared_params: SharedParams,
|
||||
|
||||
/// The execution strategy that should be used for benchmarks
|
||||
#[structopt(
|
||||
long = "execution",
|
||||
value_name = "STRATEGY",
|
||||
possible_values = &ExecutionStrategy::variants(),
|
||||
case_insensitive = true,
|
||||
)]
|
||||
pub execution: Option<ExecutionStrategy>,
|
||||
|
||||
/// Method for executing Wasm runtime code.
|
||||
#[structopt(
|
||||
long = "wasm-execution",
|
||||
value_name = "METHOD",
|
||||
possible_values = &WasmExecutionMethod::enabled_variants(),
|
||||
case_insensitive = true,
|
||||
default_value = "Interpreted"
|
||||
)]
|
||||
pub wasm_method: WasmExecutionMethod,
|
||||
}
|
||||
|
||||
/// All core commands that are provided by default.
|
||||
///
|
||||
/// The core commands are split into multiple subcommands and `Run` is the default subcommand. From
|
||||
@@ -869,6 +912,9 @@ pub enum Subcommand {
|
||||
|
||||
/// Remove the whole chain data.
|
||||
PurgeChain(PurgeChainCmd),
|
||||
|
||||
/// Run runtime benchmarks.
|
||||
Benchmark(BenchmarkCmd),
|
||||
}
|
||||
|
||||
impl Subcommand {
|
||||
@@ -883,6 +929,7 @@ impl Subcommand {
|
||||
CheckBlock(params) => ¶ms.shared_params,
|
||||
Revert(params) => ¶ms.shared_params,
|
||||
PurgeChain(params) => ¶ms.shared_params,
|
||||
Benchmark(params) => ¶ms.shared_params,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -909,6 +956,7 @@ impl Subcommand {
|
||||
Subcommand::ImportBlocks(cmd) => cmd.run(config, builder),
|
||||
Subcommand::CheckBlock(cmd) => cmd.run(config, builder),
|
||||
Subcommand::PurgeChain(cmd) => cmd.run(config),
|
||||
Subcommand::Benchmark(cmd) => cmd.run(config, builder),
|
||||
Subcommand::Revert(cmd) => cmd.run(config, builder),
|
||||
}
|
||||
}
|
||||
@@ -1186,3 +1234,32 @@ impl RevertCmd {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl BenchmarkCmd {
|
||||
/// Runs the command and benchmarks the chain.
|
||||
pub fn run<G, E, B, BC, BB>(
|
||||
self,
|
||||
config: Configuration<G, E>,
|
||||
_builder: B,
|
||||
) -> error::Result<()>
|
||||
where
|
||||
B: FnOnce(Configuration<G, E>) -> Result<BC, sc_service::error::Error>,
|
||||
G: RuntimeGenesis,
|
||||
E: ChainSpecExtension,
|
||||
BC: ServiceBuilderCommand<Block = BB> + Unpin,
|
||||
BB: sp_runtime::traits::Block + Debug,
|
||||
<<<BB as BlockT>::Header as HeaderT>::Number as std::str::FromStr>::Err: std::fmt::Debug,
|
||||
<BB as BlockT>::Hash: std::str::FromStr,
|
||||
{
|
||||
let spec = config.chain_spec.expect("chain_spec is always Some");
|
||||
let execution_strategy = self.execution.unwrap_or(ExecutionStrategy::Native).into();
|
||||
let wasm_method = self.wasm_method.into();
|
||||
let pallet = self.pallet;
|
||||
let extrinsic = self.extrinsic;
|
||||
let steps = self.steps;
|
||||
let repeat = self.repeat;
|
||||
sc_service::chain_ops::benchmark_runtime::<BB, BC::NativeDispatch, _, _>(spec, execution_strategy, wasm_method, pallet, extrinsic, steps, repeat)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user