Skip to content

Commit

Permalink
pkg/report: make use of builtin min/max function
Browse files Browse the repository at this point in the history
This patch eliminates the minDuration and maxDuration functions,
simplifies the code.

Signed-off-by: Jes Cok <[email protected]>
  • Loading branch information
callthingsoff committed May 7, 2024
1 parent 126e0d5 commit 6b517bf
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions pkg/report/timeseries.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit 6b517bf

Please sign in to comment.