-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbench_test.go
More file actions
87 lines (65 loc) · 1.33 KB
/
Copy pathbench_test.go
File metadata and controls
87 lines (65 loc) · 1.33 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright (c) 2012, Jack Christopher Kastorff
// All rights reserved.
// BSD Licensed, see LICENSE for details.
package alias
import (
"math/rand"
"testing"
)
func benchGen(b *testing.B, size int) {
b.StopTimer()
arr := make([]float64, size)
for i := 0; i < size; i++ {
arr[i] = rand.Float64()
}
a, err := New(arr)
if err != nil {
b.Error("Got an error during creation:", err)
}
rng := rand.New(rand.NewSource(99))
b.StartTimer()
for i := 0; i < b.N; i++ {
a.Gen(rng)
}
}
func BenchmarkGen5(b *testing.B) {
benchGen(b, 5)
}
func BenchmarkGen50(b *testing.B) {
benchGen(b, 50)
}
func BenchmarkGen500(b *testing.B) {
benchGen(b, 500)
}
func BenchmarkGen5000(b *testing.B) {
benchGen(b, 5000)
}
func BenchmarkGen50000(b *testing.B) {
benchGen(b, 50000)
}
func benchCreationSize(b *testing.B, size int) {
b.StopTimer()
arr := make([]float64, size)
for i := 0; i < size; i++ {
arr[i] = rand.Float64()
}
b.StartTimer()
for i := 0; i < b.N; i++ {
New(arr)
}
}
func BenchmarkCreate5(b *testing.B) {
benchCreationSize(b, 5)
}
func BenchmarkCreate50(b *testing.B) {
benchCreationSize(b, 50)
}
func BenchmarkCreate500(b *testing.B) {
benchCreationSize(b, 500)
}
func BenchmarkCreate5000(b *testing.B) {
benchCreationSize(b, 5000)
}
func BenchmarkCreate50000(b *testing.B) {
benchCreationSize(b, 50000)
}