Skip to content

Commit 9fb381c

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

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tarantool_test.go

+10
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.Fatal("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.Fatal("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,7 @@ func BenchmarkClientParallelMassive(b *testing.B) {
307314
}
308315
}()
309316
}
317+
b.ResetTimer()
310318
for i := 0; i < b.N; i++ {
311319
wg.Add(1)
312320
limit <- struct{}{}
@@ -344,6 +352,8 @@ func BenchmarkClientParallelMassiveUntyped(b *testing.B) {
344352
}
345353
}()
346354
}
355+
356+
b.ResetTimer()
347357
for i := 0; i < b.N; i++ {
348358
wg.Add(1)
349359
limit <- struct{}{}

0 commit comments

Comments
 (0)