forked from extern/nushell
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:
@ -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));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user