Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
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
imp function comparison
  • Loading branch information
itmilos committed Apr 16, 2023
commit e85f14adec313e71b91f8f11e0b1efcb48ae6c2d
23 changes: 6 additions & 17 deletions bin/node/bench/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,13 @@ pub struct NsFormatter(pub u64);
impl fmt::Display for NsFormatter {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let v = self.0;

if v < 100 {
return write!(f, "{} ns", v)
}

if self.0 < 100_000 {
return write!(f, "{:.1} µs", v as f64 / 1000.0)
}

if self.0 < 1_000_000 {
return write!(f, "{:.4} ms", v as f64 / 1_000_000.0)
}

if self.0 < 100_000_000 {
return write!(f, "{:.1} ms", v as f64 / 1_000_000.0)
match v {
v if v < 100 => write!(f, "{} ns", v),
v if v < 100_000 => write!(f, "{:.1} µs", v as f64 / 1000.0),
v if v < 1_000_000 => write!(f, "{:.4} ms", v as f64 / 1_000_000.0),
v if v < 100_000_000 => write!(f, "{:.1} ms", v as f64 / 1_000_000.0),
_ => write!(f, "{:.4} s", v as f64 / 1_000_000_000.0),
}

write!(f, "{:.4} s", v as f64 / 1_000_000_000.0)
}
}

Expand Down