-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy patharray_test.go
More file actions
42 lines (35 loc) · 645 Bytes
/
array_test.go
File metadata and controls
42 lines (35 loc) · 645 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
package gocostmodel
import "testing"
var (
v1 = [...]int{1, 2, 3, 4, 5}
v2 = [...]int{1, 2, 3, 4, 5}
v3 = [...]int{1, 2, 3, 4, 5}
sl1 = []int{5, 6, 7}
ix = 1
sln int
)
func BenchmarkArrayIndex(b *testing.B) {
for i := 0; i < b.N; i++ {
v1[ix] = i1
}
}
func BenchmarkArrayIndex2(b *testing.B) {
for i := 0; i < b.N; i++ {
v1[v2[ix]] = i1
}
}
func BenchmarkArrayIndex3(b *testing.B) {
for i := 0; i < b.N; i++ {
v1[v2[v3[ix]]] = i1
}
}
func BenchmarkArraySlicing(b *testing.B) {
for i := 0; i < b.N; i++ {
sl1 = v1[1:3]
}
}
func BenchmarkSliceIndex(b *testing.B) {
for i := 0; i < b.N; i++ {
sln = sl1[ix]
}
}