-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhashfunc_bench_test.go
100 lines (98 loc) · 2.32 KB
/
hashfunc_bench_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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package hashmap
import (
"testing"
)
type HashFuncBenchKey struct {
key Key
}
// Helpers
func benchmarkIntHashFunc(b *testing.B, blockSize int) {
for i := 0; i < b.N; i++ {
hashFunc(blockSize, i)
}
}
func benchmarkStringHashFunc(b *testing.B, blockSize int) {
for i := 0; i < b.N; i++ {
hashFunc(blockSize, string(i))
}
}
func benchmarkSliceHashFunc(b *testing.B, blockSize int) {
for i := 0; i < b.N; i++ {
hashFunc(blockSize, []int{i})
}
}
func benchmarkMapHashFunc(b *testing.B, blockSize int) {
for i := 0; i < b.N; i++ {
hashFunc(blockSize, map[string]int{string(i):i})
}
}
func benchmarkStructHashFunc(b *testing.B, blockSize int) {
for i := 0; i < b.N; i++ {
hashFunc(blockSize, HashFuncBenchKey{i})
}
}
// Int
func BenchmarkIntHashFunc16(b *testing.B) {
benchmarkIntHashFunc(b, 16)
}
func BenchmarkIntHashFunc64(b *testing.B) {
benchmarkIntHashFunc(b, 64)
}
func BenchmarkIntHashFunc128(b *testing.B) {
benchmarkIntHashFunc(b, 128)
}
func BenchmarkIntHashFunc1024(b *testing.B) {
benchmarkIntHashFunc(b, 1024)
}
// String
func BenchmarkStringHashFunc16(b *testing.B) {
benchmarkStringHashFunc(b, 16)
}
func BenchmarkStringHashFunc64(b *testing.B) {
benchmarkStringHashFunc(b, 64)
}
func BenchmarkStringHashFunc128(b *testing.B) {
benchmarkStringHashFunc(b, 128)
}
func BenchmarkStringHashFunc1024(b *testing.B) {
benchmarkStringHashFunc(b, 1024)
}
// Slice
func BenchmarkSliceHashFunc16(b *testing.B) {
benchmarkSliceHashFunc(b, 16)
}
func BenchmarkSliceHashFunc64(b *testing.B) {
benchmarkSliceHashFunc(b, 64)
}
func BenchmarkSliceHashFunc128(b *testing.B) {
benchmarkSliceHashFunc(b, 128)
}
func BenchmarkSliceHashFunc1024(b *testing.B) {
benchmarkSliceHashFunc(b, 1024)
}
// Map
func BenchmarkMapHashFunc16(b *testing.B) {
benchmarkMapHashFunc(b, 16)
}
func BenchmarkMapHashFunc64(b *testing.B) {
benchmarkMapHashFunc(b, 64)
}
func BenchmarkMapHashFunc128(b *testing.B) {
benchmarkMapHashFunc(b, 128)
}
func BenchmarkMapHashFunc1024(b *testing.B) {
benchmarkMapHashFunc(b, 1024)
}
// Struct
func BenchmarkStructHashFunc16(b *testing.B) {
benchmarkStructHashFunc(b, 16)
}
func BenchmarkStructHashFunc64(b *testing.B) {
benchmarkStructHashFunc(b, 64)
}
func BenchmarkStructHashFunc128(b *testing.B) {
benchmarkStructHashFunc(b, 128)
}
func BenchmarkStructHashFunc1024(b *testing.B) {
benchmarkStructHashFunc(b, 1024)
}