Skip to content

Commit 34b9d0e

Browse files
committed
test: fix incorrect perf measurement
Added calls of b.ResetTimer() to all Benchmark tests before bench loop. That call clears all counters of allocs, timers etc. The preparation before bench loop affected perf results. Follows up #122
1 parent e9b9ba1 commit 34b9d0e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tarantool_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func BenchmarkClientSerial(b *testing.B) {
8181
b.Errorf("No connection available")
8282
}
8383

84+
b.ResetTimer()
8485
for i := 0; i < b.N; i++ {
8586
_, err = conn.Select(spaceNo, indexNo, 0, 1, IterEq, []interface{}{uint(1111)})
8687
if err != nil {
@@ -105,6 +106,7 @@ func BenchmarkClientSerialTyped(b *testing.B) {
105106
}
106107

107108
var r []Tuple
109+
b.ResetTimer()
108110
for i := 0; i < b.N; i++ {
109111
err = conn.SelectTyped(spaceNo, indexNo, 0, 1, IterEq, IntKey{1111}, &r)
110112
if err != nil {
@@ -128,6 +130,7 @@ func BenchmarkClientFuture(b *testing.B) {
128130
b.Error(err)
129131
}
130132

133+
b.ResetTimer()
131134
for i := 0; i < b.N; i += N {
132135
var fs [N]*Future
133136
for j := 0; j < N; j++ {
@@ -158,6 +161,7 @@ func BenchmarkClientFutureTyped(b *testing.B) {
158161
b.Errorf("No connection available")
159162
}
160163

164+
b.ResetTimer()
161165
for i := 0; i < b.N; i += N {
162166
var fs [N]*Future
163167
for j := 0; j < N; j++ {
@@ -191,6 +195,7 @@ func BenchmarkClientFutureParallel(b *testing.B) {
191195
b.Errorf("No connection available")
192196
}
193197

198+
b.ResetTimer()
194199
b.RunParallel(func(pb *testing.PB) {
195200
exit := false
196201
for !exit {
@@ -227,6 +232,7 @@ func BenchmarkClientFutureParallelTyped(b *testing.B) {
227232
b.Errorf("No connection available")
228233
}
229234

235+
b.ResetTimer()
230236
b.RunParallel(func(pb *testing.PB) {
231237
exit := false
232238
for !exit {
@@ -266,6 +272,7 @@ func BenchmarkClientParallel(b *testing.B) {
266272
b.Errorf("No connection available")
267273
}
268274

275+
b.ResetTimer()
269276
b.RunParallel(func(pb *testing.PB) {
270277
for pb.Next() {
271278
_, err := conn.Select(spaceNo, indexNo, 0, 1, IterEq, []interface{}{uint(1111)})
@@ -307,6 +314,8 @@ func BenchmarkClientParallelMassive(b *testing.B) {
307314
}
308315
}()
309316
}
317+
318+
b.ResetTimer()
310319
for i := 0; i < b.N; i++ {
311320
wg.Add(1)
312321
limit <- struct{}{}
@@ -344,6 +353,8 @@ func BenchmarkClientParallelMassiveUntyped(b *testing.B) {
344353
}
345354
}()
346355
}
356+
357+
b.ResetTimer()
347358
for i := 0; i < b.N; i++ {
348359
wg.Add(1)
349360
limit <- struct{}{}

0 commit comments

Comments
 (0)