-
Notifications
You must be signed in to change notification settings - Fork 7
/
baseline_function_benchmark_test.go
181 lines (154 loc) · 3.26 KB
/
baseline_function_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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
package gospeed
import (
"fmt"
"testing"
)
func BenchmarkBaselineFunctionCall(b *testing.B) {
for i := 0; i < b.N; i++ {
f()
}
}
func BenchmarkBaselineFunctionCallArg1(b *testing.B) {
for i := 0; i < b.N; i++ {
farg1(0)
}
}
func BenchmarkBaselineFunctionCallArg2(b *testing.B) {
for i := 0; i < b.N; i++ {
farg2(0, 1)
}
}
func BenchmarkBaselineFunctionCallArg3(b *testing.B) {
for i := 0; i < b.N; i++ {
farg3(0, 1, 2)
}
}
func BenchmarkBaselineFunctionCallArg4(b *testing.B) {
for i := 0; i < b.N; i++ {
farg4(0, 1, 2, 3)
}
}
func BenchmarkBaselineFunctionCallArg5(b *testing.B) {
for i := 0; i < b.N; i++ {
farg5(0, 1, 2, 3, 4)
}
}
func BenchmarkBaselineFunctionCallArg6(b *testing.B) {
for i := 0; i < b.N; i++ {
farg6(0, 1, 2, 3, 4, 5)
}
}
func BenchmarkBaselineFunctionCallArg7(b *testing.B) {
for i := 0; i < b.N; i++ {
farg7(0, 1, 2, 3, 4, 5, 6)
}
}
func BenchmarkBaselineFunctionCallArg8(b *testing.B) {
for i := 0; i < b.N; i++ {
farg8(0, 1, 2, 3, 4, 5, 6, 7)
}
}
func BenchmarkBaselineFunctionCallArg9(b *testing.B) {
for i := 0; i < b.N; i++ {
farg9(0, 1, 2, 3, 4, 5, 6, 7, 8)
}
}
func BenchmarkBaselineFunctionCallArg10(b *testing.B) {
for i := 0; i < b.N; i++ {
farg10(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
}
}
func BenchmarkBaselineFunctionCallInt1(b *testing.B) {
for i := 0; i < b.N; i++ {
fint1(0)
}
}
func BenchmarkBaselineFunctionCallInt2(b *testing.B) {
for i := 0; i < b.N; i++ {
fint2(0, 1)
}
}
func BenchmarkBaselineFunctionCallInt3(b *testing.B) {
for i := 0; i < b.N; i++ {
fint3(0, 1, 2)
}
}
func BenchmarkBaselineFunctionCallInt4(b *testing.B) {
for i := 0; i < b.N; i++ {
fint4(0, 1, 2, 3)
}
}
func BenchmarkBaselineFunctionCallInt5(b *testing.B) {
for i := 0; i < b.N; i++ {
fint5(0, 1, 2, 3, 4)
}
}
func BenchmarkBaselineFunctionCallInt6(b *testing.B) {
for i := 0; i < b.N; i++ {
fint6(0, 1, 2, 3, 4, 5)
}
}
func BenchmarkBaselineFunctionCallInt7(b *testing.B) {
for i := 0; i < b.N; i++ {
fint7(0, 1, 2, 3, 4, 5, 6)
}
}
func BenchmarkBaselineFunctionCallInt8(b *testing.B) {
for i := 0; i < b.N; i++ {
fint8(0, 1, 2, 3, 4, 5, 6, 7)
}
}
func BenchmarkBaselineFunctionCallInt9(b *testing.B) {
for i := 0; i < b.N; i++ {
fint9(0, 1, 2, 3, 4, 5, 6, 7, 8)
}
}
func BenchmarkBaselineFunctionCallInt10(b *testing.B) {
for i := 0; i < b.N; i++ {
fint10(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
}
}
func BenchmarkBaselineFunctionCallVarArgs(b *testing.B) {
for _, v := range scaling_slices {
vv := make([]any, len(v))
for i, w := range v {
vv[i] = w
}
b.Run(fmt.Sprintf("count_%v", len(vv)), func(b *testing.B) {
for i := 0; i < b.N; i++ {
fvarargs(vv...)
}
})
}
}
func BenchmarkBaselineFunctionCallVarInts(b *testing.B) {
for _, v := range scaling_slices {
b.Run(fmt.Sprintf("count_%v", len(v)), func(b *testing.B) {
for i := 0; i < b.N; i++ {
fvarints(v...)
}
})
}
}
func BenchmarkBaselineFunctionInlineCallWithDefer(b *testing.B) {
for i := 0; i < b.N; i++ {
func() {
defer func() {}()
}()
}
}
func BenchmarkBaselineFunctionVariableCallWithDefer(b *testing.B) {
b.StopTimer()
f := func() {
defer func() {}()
}
b.StartTimer()
for i := 0; i < b.N; i++ {
f()
}
}
func BenchmarkBaselineDefer(b *testing.B) {
for i := 0; i < b.N; i++ {
defer func() {}()
}
}