From 9563e5951d596ea1fbf80e42be6dc27c6df1d3c5 Mon Sep 17 00:00:00 2001 From: Fabian Holler Date: Thu, 20 Jun 2024 13:13:56 +0200 Subject: [PATCH] output: shorten printed duration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - truncate durations >=1 minute to 1 second precision, - truncate durations >=1 second to 1 millisecond precision, - limit precision to max. 1µs, --- internal/command/term/format.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/command/term/format.go b/internal/command/term/format.go index 9384462db..f2f4fd7fb 100644 --- a/internal/command/term/format.go +++ b/internal/command/term/format.go @@ -53,13 +53,13 @@ func FormatDuration(d time.Duration, opts ...FormatOption) string { return fmt.Sprintf("%.3f", d.Seconds()) } - if d.Minutes() > 1 { - return d.Round(time.Second).String() + if d.Minutes() >= 1 { + return d.Truncate(time.Second).String() } - if d.Milliseconds() > 1 { - return d.Round(time.Millisecond).String() + if d.Seconds() >= 1 { + return d.Truncate(time.Millisecond).String() } - return d.String() + return d.Truncate(time.Microsecond).String() }