lib/decimal: use consistent randomizer in tests

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3683
This commit is contained in:
Aliaksandr Valialkin 2023-01-23 19:23:37 -08:00
parent 0a4d8dc777
commit a11dc6689a
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1
2 changed files with 6 additions and 3 deletions

View File

@ -506,8 +506,9 @@ func TestFloatToDecimalRoundtrip(t *testing.T) {
f(vMin)
f(vStaleNaN)
r := rand.New(rand.NewSource(1))
for i := 0; i < 1e4; i++ {
v := rand.NormFloat64()
v := r.NormFloat64()
f(v)
f(v * 1e-6)
f(v * 1e6)

View File

@ -84,17 +84,19 @@ func benchmarkAppendFloatToDecimal(b *testing.B, fa []float64) {
}
var testFAReal = func() []float64 {
r := rand.New(rand.NewSource(1))
fa := make([]float64, 8*1024)
for i := 0; i < len(fa); i++ {
fa[i] = rand.NormFloat64() * 1e-6
fa[i] = r.NormFloat64() * 1e-6
}
return fa
}()
var testFAInteger = func() []float64 {
r := rand.New(rand.NewSource(2))
fa := make([]float64, 8*1024)
for i := 0; i < len(fa); i++ {
fa[i] = float64(int(rand.NormFloat64() * 1e6))
fa[i] = float64(int(r.NormFloat64() * 1e6))
}
return fa
}()