Skip to main content

humanize_duration

Function humanize_duration 

pub fn humanize_duration(d: Duration) -> String
Expand description

Convert a Duration to a short human-readable string. Breakpoints chosen to match the cargo / pytest / npm convention:

  • < 1ms"<1ms" (avoid useless 0.0s for very fast no-op runs)
  • < 1s"234ms" (sub-second resolution in ms)
  • < 60s"4.3s" (one decimal place; resolution-vs-noise compromise)
  • < 1h"2m 34s" (no fractional component above a minute)
  • ≥ 1h"1h 5m 12s" (rare for codelore but cheap to support)