-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbase_test.go
More file actions
49 lines (43 loc) · 895 Bytes
/
Copy pathbase_test.go
File metadata and controls
49 lines (43 loc) · 895 Bytes
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
package dice
import (
"fmt"
"math/rand"
"testing"
)
// Ensure csprngSource statisfies the rand.Source64 interface; rand.Source64
// sources use half the entropy of a regular rand.Source.
var _ = (rand.Source64)(&csprngSource{})
// Set of basic range sizes.
var benchmarks = []struct {
size int
}{
{6},
{20},
{100},
}
func BenchmarkSource_Intn(b *testing.B) {
b.ReportAllocs()
for _, bmark := range benchmarks {
b.Run(fmt.Sprintf("%d", bmark.size), func(b *testing.B) {
for n := 0; n < b.N; n++ {
Source.Intn(bmark.size)
}
})
}
}
func BenchmarkCryptoIntn(b *testing.B) {
b.ReportAllocs()
for _, bmark := range benchmarks {
b.Run(fmt.Sprintf("%d", bmark.size), func(b *testing.B) {
for n := 0; n < b.N; n++ {
CryptoIntn(bmark.size)
}
})
}
}
func BenchmarkCryptoInt64(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
CryptoInt64()
}
}