-
Notifications
You must be signed in to change notification settings - Fork 20
/
hash64_test.go
74 lines (68 loc) · 1.13 KB
/
hash64_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
package xxh3
import (
"fmt"
"runtime"
"testing"
)
func BenchmarkFixed64(b *testing.B) {
r := func(i int) {
bench := func(b *testing.B) {
var acc uint64
d := string(make([]byte, i))
b.Run("default", func(b *testing.B) {
b.SetBytes(int64(i))
b.ResetTimer()
for i := 0; i < b.N; i++ {
acc = HashString(d)
}
runtime.KeepAlive(acc)
})
b.Run("seed", func(b *testing.B) {
b.SetBytes(int64(i))
b.ResetTimer()
for i := 0; i < b.N; i++ {
acc = HashStringSeed(d, 42)
}
runtime.KeepAlive(acc)
})
}
if i > 240 {
if i >= avx512Switch && hasAVX512 {
withAVX512(func() { b.Run(fmt.Sprintf("%d-AVX512", i), bench) })
}
if hasAVX2 {
withAVX2(func() { b.Run(fmt.Sprintf("%d-AVX2", i), bench) })
}
if hasSSE2 {
withSSE2(func() { b.Run(fmt.Sprintf("%d-SSE2", i), bench) })
}
}
withGeneric(func() { b.Run(fmt.Sprintf("%d", i), bench) })
}
r(0)
r(1)
r(2)
r(3)
r(4)
r(8)
r(9)
r(16)
r(17)
r(32)
r(33)
r(64)
r(65)
r(96)
r(97)
r(128)
r(129)
r(240)
r(241)
r(512)
r(1024)
r(8192)
r(100 * 1024)
r(1000 * 1024)
r(10000 * 1024)
r(100000 * 1024)
}