From 6b517bfb4bd7b63a7d0ed791c2e89afc4ce6753f Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Tue, 7 May 2024 22:33:17 +0800 Subject: [PATCH] pkg/report: make use of builtin min/max function This patch eliminates the minDuration and maxDuration functions, simplifies the code. Signed-off-by: Jes Cok --- pkg/report/timeseries.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/pkg/report/timeseries.go b/pkg/report/timeseries.go index 2005ee5e36a..6f5ed8c4a54 100644 --- a/pkg/report/timeseries.go +++ b/pkg/report/timeseries.go @@ -64,9 +64,9 @@ func (sp *secondPoints) Add(ts time.Time, lat time.Duration) { sp.tm[tk] = secondPoint{minLatency: lat, maxLatency: lat, totalLatency: lat, count: 1} } else { if lat != time.Duration(0) { - v.minLatency = minDuration(v.minLatency, lat) + v.minLatency = min(v.minLatency, lat) } - v.maxLatency = maxDuration(v.maxLatency, lat) + v.maxLatency = max(v.maxLatency, lat) v.totalLatency += lat v.count++ sp.tm[tk] = v @@ -144,17 +144,3 @@ func (t TimeSeries) String() string { } return fmt.Sprintf("\nSample in one second (unix latency throughput):\n%s", buf.String()) } - -func minDuration(a, b time.Duration) time.Duration { - if a < b { - return a - } - return b -} - -func maxDuration(a, b time.Duration) time.Duration { - if a > b { - return a - } - return b -}