mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
More Improvements to Benchmarking CLI + Generic WeightInfo (#7168)
* Generic WeightInfo, Output File Path * Make `WeightInfo` generic * Add support for header file * fix line width * add `--spaces` flag * Configurable trait and struct strings * make elections phragmen generic * Add date to generated file * Apply suggestions from code review Co-authored-by: Gavin Wood <gavin@parity.io> * fixes * add settings metadata to output Co-authored-by: nikvolf <nikvolf@gmail.com> Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
@@ -41,6 +41,14 @@ impl BenchmarkCmd {
|
||||
<BB as BlockT>::Hash: std::str::FromStr,
|
||||
ExecDispatch: NativeExecutionDispatch + 'static,
|
||||
{
|
||||
if let Some(output_path) = &self.output {
|
||||
if !output_path.is_dir() { return Err("Output path is invalid!".into()) };
|
||||
}
|
||||
|
||||
if let Some(header_file) = &self.header {
|
||||
if !header_file.is_file() { return Err("Header file is invalid!".into()) };
|
||||
}
|
||||
|
||||
let spec = config.chain_spec;
|
||||
let wasm_method = self.wasm_method.into();
|
||||
let strategy = self.execution.unwrap_or(ExecutionStrategy::Native);
|
||||
@@ -91,12 +99,22 @@ impl BenchmarkCmd {
|
||||
match results {
|
||||
Ok(batches) => {
|
||||
// If we are going to output results to a file...
|
||||
if self.output {
|
||||
if self.weight_trait {
|
||||
let mut file = crate::writer::open_file("traits.rs")?;
|
||||
crate::writer::write_trait(&mut file, batches.clone())?;
|
||||
if let Some(output_path) = &self.output {
|
||||
if self.trait_def {
|
||||
crate::writer::write_trait(&batches, output_path, &self.r#trait, self.spaces)?;
|
||||
} else {
|
||||
crate::writer::write_results(&batches)?;
|
||||
crate::writer::write_results(
|
||||
&batches,
|
||||
output_path,
|
||||
&self.lowest_range_values,
|
||||
&self.highest_range_values,
|
||||
&self.steps,
|
||||
self.repeat,
|
||||
&self.header,
|
||||
&self.r#struct,
|
||||
&self.r#trait,
|
||||
self.spaces
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user