-
Notifications
You must be signed in to change notification settings - Fork 2
/
random_test.go
73 lines (64 loc) · 1.25 KB
/
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
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"io"
"io/ioutil"
"math/rand"
"testing"
rand7i "github.com/7i/rand"
mewrand "github.com/sanctuary/d1/rand"
"github.com/seehuhn/mt19937"
)
const toCopy = 1024 * 1024
func BenchmarkRandbo(b *testing.B) {
b.SetBytes(toCopy)
r := New()
b.ResetTimer()
for i := 0; i < b.N; i++ {
io.CopyN(ioutil.Discard, r, toCopy)
}
}
func BenchmarkRand(b *testing.B) {
var rprim = rand.New(rand.NewSource(0))
b.SetBytes(toCopy)
b.ResetTimer()
for i := 0; i < b.N; i++ {
io.CopyN(ioutil.Discard, rprim, toCopy)
}
}
func BenchmarkMewRand(b *testing.B) {
b.SetBytes(toCopy)
b.ResetTimer()
for i := 0; i < b.N; i++ {
for j := 0; j < toCopy; j += 4 {
mewrand.Int()
}
}
}
func BenchmarkMt(b *testing.B) {
mt := mt19937.New()
b.SetBytes(toCopy)
b.ResetTimer()
for i := 0; i < b.N; i++ {
io.CopyN(ioutil.Discard, mt, toCopy)
}
}
func Benchmark7iComplex128(b *testing.B) {
rng := rand7i.NewComplexRNG(0)
b.SetBytes(toCopy)
b.ResetTimer()
for i := 0; i < b.N; i++ {
for j := 0; j < toCopy; j += 16 {
rng.Complex128()
}
}
}
func Benchmark7iComplex128Go(b *testing.B) {
rng := rand7i.NewComplexRNG(0)
b.SetBytes(toCopy)
b.ResetTimer()
for i := 0; i < b.N; i++ {
for j := 0; j < toCopy; j += 16 {
rng.Complex128Go()
}
}
}