Skip to content

Commit ae07ac9

Browse files
committed
state: use more idiomatic rounding
1 parent 6ea7bc3 commit ae07ac9

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

pkg/kv/kvserver/asim/history/thrashing_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package history
88
import (
99
"fmt"
1010
"math"
11-
"strconv"
1211
"strings"
1312
"testing"
1413
"testing/quick"
@@ -23,14 +22,9 @@ import (
2322
)
2423

2524
func tsFromFunc(ticks int, f func(tick int) float64) []float64 {
26-
roundToSixDigits := func(num float64) float64 {
27-
formatted := fmt.Sprintf("%.6f", num)
28-
result, _ := strconv.ParseFloat(formatted, 64)
29-
return result
30-
}
3125
vs := make([]float64, ticks)
3226
for i := 0; i < ticks; i++ {
33-
vs[i] = roundToSixDigits(f(i))
27+
vs[i] = math.Round(f(i)*1e6) / 1e6
3428
}
3529
return vs
3630
}

0 commit comments

Comments
 (0)