Use Handlebars Template for Benchmark CLI Output (#7390)

* add_handlebar_template_to_benchmark

- add benchmark-cli arg to take in a handlebar-template file

* update to always use template

* rewrite writer for handlebars

* polish

* pass cmd data

* update docs

* support custom filename output

* Update command.rs

* Create frame-weight-template.hbs

* use a vector to maintain benchmark order

* fix tests

* Custom string serializer, remove feature flag

* update docs

* docs on public objects

* small fix

Co-authored-by: Ezadkiel Marbella <zadkiel.m@gmail.com>
This commit is contained in:
Shawn Tabrizi
2020-10-27 13:25:57 +01:00
committed by GitHub
parent 21d1cd0c89
commit 3ac070b61e
8 changed files with 598 additions and 316 deletions
@@ -43,13 +43,19 @@ impl BenchmarkCmd {
ExecDispatch: NativeExecutionDispatch + 'static,
{
if let Some(output_path) = &self.output {
if !output_path.is_dir() { return Err("Output path is invalid!".into()) };
if !output_path.is_dir() && output_path.file_name().is_none() {
return Err("Output file or path is invalid!".into())
}
}
if let Some(header_file) = &self.header {
if !header_file.is_file() { return Err("Header file is invalid!".into()) };
}
if let Some(handlebars_template_file) = &self.template {
if !handlebars_template_file.is_file() { return Err("Handlebars template file is invalid!".into()) };
}
let spec = config.chain_spec;
let wasm_method = self.wasm_method.into();
let strategy = self.execution.unwrap_or(ExecutionStrategy::Native);
@@ -99,13 +105,8 @@ impl BenchmarkCmd {
match results {
Ok(batches) => {
// If we are going to output results to a file...
if let Some(output_path) = &self.output {
if self.trait_def {
crate::writer::write_trait(&batches, output_path, self)?;
} else {
crate::writer::write_results(&batches, output_path, self)?;
}
crate::writer::write_results(&batches, output_path, self)?;
}
for batch in batches.into_iter() {