Skip to content

Commit

Permalink
Merge pull request #17963 from callthingsoff/use_min_max
Browse files Browse the repository at this point in the history
pkg/report: make use of builtin min/max function
  • Loading branch information
ahrtr authored May 8, 2024
2 parents fef4236 + 6b517bf commit 7bff148
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 7bff148

Please sign in to comment.