use a better time format than raw humantime

This commit is contained in:
Jonathan Kelley committed 2026-01-16 18:22:58 -08:00
1 parent 10eda3a794
commit 58eea846b9
4 files changed
+149 -145

No files matched your search

-1
View File
@@ -108,7 +108,6 @@ tracing-subscriber = { version = "0.3.19", features = [
"fmt",
] }
console-subscriber = { version = "0.4.1", optional = true }
humantime = "2.2.0"
tracing = { workspace = true }
ansi-to-tui = { workspace = true }
ansi-to-html = { workspace = true }
+9 -4
View File
@@ -1309,9 +1309,14 @@ fn is_wsl() -> bool {
false
}
/// Format a Duration for human-readable output with millisecond precision.
/// Format a Duration for human-readable output.
fn format_duration_ms(d: Duration) -> String {
// Format duration with millisecond precision to avoid microsecond/nanosecond noise.
// See: https://github.com/chronotope/humantime/issues/35
humantime::format_duration(Duration::from_millis(d.as_millis() as u64)).to_string()
let total_ms = d.as_millis() as u64;
if total_ms < 1000 {
format!("{total_ms}ms")
} else {
let secs = total_ms as f64 / 1000.0;
format!("{secs:.2}s")
}
}