-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark_test.go
63 lines (54 loc) · 1.08 KB
/
benchmark_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
package main
import (
"encoding/binary"
"math/rand"
"testing"
)
var (
S = rand.NewSource(10)
R = rand.New(S)
res []uint32
)
func BenchmarkAddUInt(b *testing.B) {
for i := 0; i < b.N; i++ {
addUInt(R.Uint32(), R.Uint32())
}
}
func BenchmarkAddDirect(b *testing.B) {
for i := 0; i < b.N; i++ {
addDirect(R.Uint32(), R.Uint32())
}
}
func BenchmarkRightRotate(b *testing.B) {
for i := 0; i < b.N; i++ {
rightRotate(R.Uint32(), R.Uint32())
}
}
func BenchmarkGoRotate(b *testing.B) {
for i := 0; i < b.N; i++ {
goRightRotate(R.Uint32(), R.Uint32())
}
}
func BenchmarkMessageSchedule(b *testing.B) {
token := make([]byte, 64)
R.Read(token)
for i := 0; i < b.N; i++ {
messageSchedule(token)
}
}
func BenchmarkRoundDeclare(b *testing.B) {
W := make([]uint32, 8)
binary.Read(R, binary.BigEndian, &W)
for i := 0; i < b.N; i++ {
W = roundDeclare(W, 961987163, 3221900128)
}
res = W
}
func BenchmarkRoundMutate(b *testing.B) {
W := make([]uint32, 8)
binary.Read(R, binary.BigEndian, &W)
for i := 0; i < b.N; i++ {
roundMutate(W, 961987163, 3221900128)
}
res = W
}