Skip to content

Commit b3cacff

Browse files
authored
Fix flaky unit test TestBenchmarkStateGetQuantileSuccess (#431)
1 parent 74bbcdd commit b3cacff

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

bench_state.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package main
2222

2323
import (
2424
"fmt"
25+
"math"
2526
"sort"
2627
"time"
2728

@@ -139,7 +140,7 @@ func (s *benchmarkState) getQuantile(q float64) time.Duration {
139140
rightBias := exactIdx - float64(leftIdx)
140141
leftBias := 1 - rightBias
141142

142-
return time.Duration(float64(s.latencies[leftIdx])*leftBias + float64(s.latencies[rightIdx])*rightBias)
143+
return time.Duration(math.Round(float64(s.latencies[leftIdx])*leftBias + float64(s.latencies[rightIdx])*rightBias))
143144
}
144145

145146
type byDuration []time.Duration

0 commit comments

Comments
 (0)