mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 12:31:07 +01:00
lib/decimal: use consistent randomizer in tests
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3683
This commit is contained in:
parent
0a4d8dc777
commit
a11dc6689a
@ -506,8 +506,9 @@ func TestFloatToDecimalRoundtrip(t *testing.T) {
|
|||||||
f(vMin)
|
f(vMin)
|
||||||
f(vStaleNaN)
|
f(vStaleNaN)
|
||||||
|
|
||||||
|
r := rand.New(rand.NewSource(1))
|
||||||
for i := 0; i < 1e4; i++ {
|
for i := 0; i < 1e4; i++ {
|
||||||
v := rand.NormFloat64()
|
v := r.NormFloat64()
|
||||||
f(v)
|
f(v)
|
||||||
f(v * 1e-6)
|
f(v * 1e-6)
|
||||||
f(v * 1e6)
|
f(v * 1e6)
|
||||||
|
@ -84,17 +84,19 @@ func benchmarkAppendFloatToDecimal(b *testing.B, fa []float64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var testFAReal = func() []float64 {
|
var testFAReal = func() []float64 {
|
||||||
|
r := rand.New(rand.NewSource(1))
|
||||||
fa := make([]float64, 8*1024)
|
fa := make([]float64, 8*1024)
|
||||||
for i := 0; i < len(fa); i++ {
|
for i := 0; i < len(fa); i++ {
|
||||||
fa[i] = rand.NormFloat64() * 1e-6
|
fa[i] = r.NormFloat64() * 1e-6
|
||||||
}
|
}
|
||||||
return fa
|
return fa
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var testFAInteger = func() []float64 {
|
var testFAInteger = func() []float64 {
|
||||||
|
r := rand.New(rand.NewSource(2))
|
||||||
fa := make([]float64, 8*1024)
|
fa := make([]float64, 8*1024)
|
||||||
for i := 0; i < len(fa); i++ {
|
for i := 0; i < len(fa); i++ {
|
||||||
fa[i] = float64(int(rand.NormFloat64() * 1e6))
|
fa[i] = float64(int(r.NormFloat64() * 1e6))
|
||||||
}
|
}
|
||||||
return fa
|
return fa
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user