-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
bench_extra_test.go
137 lines (120 loc) · 2.07 KB
/
bench_extra_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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package gmp
import (
"testing"
)
func BenchmarkSwapO(bench *testing.B) {
a := NewInt(1)
b := NewInt(2)
c := NewInt(0)
for i := bench.N; i > 0; i-- {
c.Set(a)
a.Set(b)
b.Set(c)
}
}
func BenchmarkSwapX(bench *testing.B) {
a := NewInt(1)
b := NewInt(2)
for i := bench.N; i > 0; i-- {
a.Swap(b)
}
}
func BenchmarkAddUintO(bench *testing.B) {
a := NewInt(1)
b := NewInt(2)
for i := bench.N; i > 0; i-- {
b.SetUint64(uint64(i))
a.Add(a, b)
}
}
func BenchmarkAddUintX(bench *testing.B) {
a := NewInt(1)
for i := bench.N; i > 0; i-- {
a.AddUint32(a, uint32(i))
}
}
func BenchmarkMulInt0(bench *testing.B) {
a := NewInt(1)
b := NewInt(2)
for i := bench.N; i > 0; i-- {
b.SetInt64(1)
a.Mul(a, b)
}
}
func BenchmarkMulIntX(bench *testing.B) {
a := NewInt(1)
for i := bench.N; i > 0; i-- {
a.MulInt32(a, 1)
}
}
func BenchmarkAddMulO(bench *testing.B) {
a := NewInt(1)
b := NewInt(2)
c := NewInt(0)
for i := bench.N; i > 0; i-- {
a.Add(a, c)
b.Mul(b, a)
}
}
func BenchmarkAddMulX(bench *testing.B) {
a := NewInt(1)
b := NewInt(2)
c := NewInt(0)
for i := bench.N; i > 0; i-- {
b.AddMul(a, c)
}
}
func BenchmarkCmpIntO(bench *testing.B) {
a := NewInt(1)
b := NewInt(2)
for i := bench.N; i > 0; i-- {
a.SetInt64(int64(i))
b.Cmp(a)
}
}
func BenchmarkCmpIntX(bench *testing.B) {
a := NewInt(1)
for i := bench.N; i > 0; i-- {
a.CmpInt32(int32(i))
}
}
func BenchmarkCmpAbsO(bench *testing.B) {
a := NewInt(1)
b := NewInt(2)
for i := bench.N; i > 0; i-- {
a.Abs(a)
b.Abs(b)
a.Cmp(b)
}
}
func BenchmarkCmpAbsX(bench *testing.B) {
a := NewInt(1)
b := NewInt(1)
for i := bench.N; i > 0; i-- {
a.CmpAbs(b)
}
}
func BenchmarkGetIntO(bench *testing.B) {
a := NewInt(1)
for i := bench.N; i > 0; i-- {
a.Int64()
}
}
func BenchmarkGetIntX(bench *testing.B) {
a := NewInt(1)
for i := bench.N; i > 0; i-- {
a.Int32()
}
}
func BenchmarkGetUintO(bench *testing.B) {
a := NewInt(1)
for i := bench.N; i > 0; i-- {
a.Uint64()
}
}
func BenchmarkGetUintX(bench *testing.B) {
a := NewInt(1)
for i := bench.N; i > 0; i-- {
a.Uint32()
}
}