-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
int_test.go
51 lines (42 loc) · 675 Bytes
/
int_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
package gocostmodel
import "testing"
var (
i1 int = 1
i2 int = 2
i3 int = 5
)
func BenchmarkIntAssign(b *testing.B) {
for i := 0; i < b.N; i++ {
i1 = i2
}
}
func BenchmarkIntInc(b *testing.B) {
for i := 0; i < b.N; i++ {
i1++
}
}
func BenchmarkIntAdd(b *testing.B) {
for i := 0; i < b.N; i++ {
i1 = i2 + i3
}
}
func BenchmarkIntSub(b *testing.B) {
for i := 0; i < b.N; i++ {
i1 = i2 - i3
}
}
func BenchmarkIntMul(b *testing.B) {
for i := 0; i < b.N; i++ {
i1 = i2 * i3
}
}
func BenchmarkIntDiv(b *testing.B) {
for i := 0; i < b.N; i++ {
i1 = i2 / i3
}
}
func BenchmarkIntMod(b *testing.B) {
for i := 0; i < b.N; i++ {
i1 = i2 % i3
}
}