Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ fn print_summary<W: Write>(
timescale
} else {
// Use max latency (slowest request)
TimeScale::from_f64(latency_stat.max())
TimeScale::from_f64_summary(latency_stat.max())
};
writeln!(
w,
Expand Down
18 changes: 18 additions & 0 deletions src/timescale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@ impl TimeScale {
TimeScale::Nanosecond
}

/// From seconds as f64 for summary output.
/// TimeScale::TenSeconds and TimeScale::TenMinutes are not used for summary output. Because it is looked weird to see "10 sec" or "10 min" in summary output.
pub fn from_f64_summary(seconds: f64) -> Self {
for ts in &[
TimeScale::Hour,
TimeScale::Minute,
TimeScale::Second,
TimeScale::Millisecond,
TimeScale::Microsecond,
TimeScale::Nanosecond,
] {
if seconds > ts.as_secs_f64() {
return *ts;
}
}
TimeScale::Nanosecond
}

pub fn from_elapsed(duration: Duration) -> Self {
Self::from_f64(duration.as_secs_f64())
}
Expand Down
Loading