-
Notifications
You must be signed in to change notification settings - Fork 0
/
random_test.go
60 lines (52 loc) · 1014 Bytes
/
random_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package gaul
import (
"math/rand"
"testing"
)
func BenchmarkLFSRSmall_Next(b *testing.B) {
prng := NewLFSRSmall()
for i := 0; i < b.N; i++ {
prng.Next()
}
}
func BenchmarkLFSRMedium_Next(b *testing.B) {
prng := NewLFSRMedium()
for i := 0; i < b.N; i++ {
prng.Next()
}
}
func BenchmarkLFSRLarge_Next(b *testing.B) {
prng := NewLFSRLarge()
for i := 0; i < b.N; i++ {
prng.Next()
}
}
func BenchmarkLFSRLarge_Float64(b *testing.B) {
prng := NewLFSRLarge()
for i := 0; i < b.N; i++ {
prng.Float64()
}
}
func BenchmarkStandardRand_Intn(b *testing.B) {
for i := 0; i < b.N; i++ {
rand.Int63()
}
}
func BenchmarkStandardRand_Float64(b *testing.B) {
for i := 0; i < b.N; i++ {
rand.Float64()
}
}
func BenchmarkNoise(b *testing.B) {
seed := int64(1234)
rng := NewRng(seed)
xs := make([]float64, 1000)
ys := make([]float64, 1000)
for i := 0; i < 1000; i++ {
xs[i] = rand.Float64()
ys[i] = rand.Float64()
}
for i := 0; i < b.N; i++ {
rng.Noise2D(xs[i%1000], ys[i%1000])
}
}