Add system, user and idle times to benchmark command (#2571)

* Add system, user and idle times to benchmark command

* Feature-gate dependency on heim in benchmark

* Reorder let bindings in benchmark

* Fully feature-gate rich-benchmark and print 0sec on zero duration
This commit is contained in:
Radek Vít
2020-09-19 19:13:14 +02:00
committed by GitHub
parent 2b13ac3856
commit 422b6ca871
5 changed files with 91 additions and 15 deletions

View File

@ -297,6 +297,7 @@ pub fn format_primitive(primitive: &Primitive, field_name: Option<&String>) -> S
/// Format a duration in nanoseconds into a string
pub fn format_duration(duration: &BigInt) -> String {
let is_zero = duration.is_zero();
// FIXME: This involves a lot of allocation, but it seems inevitable with BigInt.
let big_int_1000 = BigInt::from(1000);
let big_int_60 = BigInt::from(60);
@ -327,8 +328,8 @@ pub fn format_duration(duration: &BigInt) -> String {
if !mins.is_zero() {
output_prep.push(format!("{}min", mins));
}
if !secs.is_zero() {
// output 0sec for zero duration
if is_zero || !secs.is_zero() {
output_prep.push(format!("{}sec", secs));
}