diff options
| author | Jeff Carr <[email protected]> | 2025-10-08 06:32:58 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-08 06:32:58 -0500 |
| commit | 58f309bec46b355e5d74bb0ba9e7f2901c4782f8 (patch) | |
| tree | 1c17f4f7f8a9ec52e2ce921d508d66064867cdad | |
| parent | a86ec5e086c3394f11a8b3cc61711a0b0e047520 (diff) | |
dig up my other version
| -rw-r--r-- | humanFormat.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/humanFormat.go b/humanFormat.go index ac195d9..e501490 100644 --- a/humanFormat.go +++ b/humanFormat.go @@ -94,16 +94,20 @@ func FormatDuration(d time.Duration) string { ms := int(d.Milliseconds()) if ms > 100 { // todo: print .3s, etc ? - return fmt.Sprintf("%1.2fs", float64(seconds)/1000) } if ms > 0 { result += fmt.Sprintf("%dms", ms) + return result + } + + // report in milliseconds + mc := int(d.Microseconds()) + if mc > 0 { + result += fmt.Sprintf("%dmc", mc) + return result } - // totally not necessary but wth - var t time.Duration - t = time.Duration(ms) * time.Millisecond - nanos := d - t - result += fmt.Sprintf("%dnanos", nanos) + ns := int(d.Nanoseconds()) + result += fmt.Sprintf("%dns", ns) return result } |
