Propagate DispatchError for benchmarks. (#5075)

* Propagate DispatchError for benchmarks.

* Apply review suggestions.

* Use RuntimeString.

* fix expect

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Marcio Diaz
2020-02-28 12:05:27 +01:00
committed by GitHub
parent 25d1b7878a
commit d39605d9cd
5 changed files with 42 additions and 34 deletions
@@ -109,34 +109,36 @@ impl BenchmarkCmd {
)
.execute(strategy.into())
.map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?;
let results = <Option<Vec<BenchmarkResults>> as Decode>::decode(&mut &result[..])
.unwrap_or(None);
if let Some(results) = results {
// Print benchmark metadata
println!(
"Pallet: {:?}, Extrinsic: {:?}, Steps: {:?}, Repeat: {:?}",
self.pallet,
self.extrinsic,
self.steps,
self.repeat,
);
let results = <Result<Vec<BenchmarkResults>, String> as Decode>::decode(&mut &result[..])
.map_err(|e| format!("Failed to decode benchmark results: {:?}", e))?;
// Print the table header
results[0].0.iter().for_each(|param| print!("{:?},", param.0));
match results {
Ok(results) => {
// Print benchmark metadata
println!(
"Pallet: {:?}, Extrinsic: {:?}, Steps: {:?}, Repeat: {:?}",
self.pallet,
self.extrinsic,
self.steps,
self.repeat,
);
print!("extrinsic_time,storage_root_time\n");
// Print the values
results.iter().for_each(|result| {
let parameters = &result.0;
parameters.iter().for_each(|param| print!("{:?},", param.1));
// Print extrinsic time and storage root time
print!("{:?},{:?}\n", result.1, result.2);
});
// Print the table header
results[0].0.iter().for_each(|param| print!("{:?},", param.0));
eprintln!("Done.");
} else {
eprintln!("No Results.");
print!("extrinsic_time,storage_root_time\n");
// Print the values
results.iter().for_each(|result| {
let parameters = &result.0;
parameters.iter().for_each(|param| print!("{:?},", param.1));
// Print extrinsic time and storage root time
print!("{:?},{:?}\n", result.1, result.2);
});
eprintln!("Done.");
}
Err(error) => eprintln!("Error: {:?}", error),
}
Ok(())