Skip to content

Commit 2bc07ed

Browse files
committed
test: fix benchmark tests names
When using go test tool with different regexp for filtering test functions, it is sometimes helpful to filter some of them with any prefix like BenchmarkClientSerial or BenchmarkClientParallel. This way it is possible to get results just for one type of load. Follows up #62 Follows up #122
1 parent d44ffa0 commit 2bc07ed

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

tarantool_test.go

+36-36
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,39 @@ func BenchmarkClientSerialTyped(b *testing.B) {
117117
}
118118
}
119119

120+
func BenchmarkClientSerialSQL(b *testing.B) {
121+
// Tarantool supports SQL since version 2.0.0
122+
isLess, err := test_helpers.IsTarantoolVersionLess(2, 0, 0)
123+
if err != nil {
124+
b.Fatal("Could not check the Tarantool version")
125+
}
126+
if isLess {
127+
b.Skip()
128+
}
129+
130+
conn, err := Connect(server, opts)
131+
if err != nil {
132+
b.Errorf("Failed to connect: %s", err)
133+
return
134+
}
135+
defer conn.Close()
136+
137+
spaceNo := 519
138+
_, err = conn.Replace(spaceNo, []interface{}{uint(1111), "hello", "world"})
139+
if err != nil {
140+
b.Errorf("Failed to replace: %s", err)
141+
}
142+
143+
b.ResetTimer()
144+
for i := 0; i < b.N; i++ {
145+
_, err := conn.Execute("SELECT NAME0,NAME1,NAME2 FROM SQL_TEST WHERE NAME0=?", []interface{}{uint(1111)})
146+
if err != nil {
147+
b.Errorf("Select failed: %s", err.Error())
148+
break
149+
}
150+
}
151+
}
152+
120153
func BenchmarkClientFuture(b *testing.B) {
121154
var err error
122155

@@ -364,7 +397,7 @@ func BenchmarkClientParallelMassiveUntyped(b *testing.B) {
364397
close(limit)
365398
}
366399

367-
func BenchmarkClientReplaceParallel(b *testing.B) {
400+
func BenchmarkClientParallelReplace(b *testing.B) {
368401
conn, err := Connect(server, opts)
369402
if err != nil {
370403
b.Errorf("No connection available")
@@ -389,7 +422,7 @@ func BenchmarkClientReplaceParallel(b *testing.B) {
389422
})
390423
}
391424

392-
func BenchmarkClientLargeSelectParallel(b *testing.B) {
425+
func BenchmarkClientParallelLargeSelect(b *testing.B) {
393426
conn, err := Connect(server, opts)
394427
if err != nil {
395428
b.Errorf("No connection available")
@@ -415,7 +448,7 @@ func BenchmarkClientLargeSelectParallel(b *testing.B) {
415448
})
416449
}
417450

418-
func BenchmarkSQLParallel(b *testing.B) {
451+
func BenchmarkClientParallelSQL(b *testing.B) {
419452
// Tarantool supports SQL since version 2.0.0
420453
isLess, err := test_helpers.IsTarantoolVersionLess(2, 0, 0)
421454
if err != nil {
@@ -450,39 +483,6 @@ func BenchmarkSQLParallel(b *testing.B) {
450483
})
451484
}
452485

453-
func BenchmarkSQLSerial(b *testing.B) {
454-
// Tarantool supports SQL since version 2.0.0
455-
isLess, err := test_helpers.IsTarantoolVersionLess(2, 0, 0)
456-
if err != nil {
457-
b.Fatal("Could not check the Tarantool version")
458-
}
459-
if isLess {
460-
b.Skip()
461-
}
462-
463-
conn, err := Connect(server, opts)
464-
if err != nil {
465-
b.Errorf("Failed to connect: %s", err)
466-
return
467-
}
468-
defer conn.Close()
469-
470-
spaceNo := 519
471-
_, err = conn.Replace(spaceNo, []interface{}{uint(1111), "hello", "world"})
472-
if err != nil {
473-
b.Errorf("Failed to replace: %s", err)
474-
}
475-
476-
b.ResetTimer()
477-
for i := 0; i < b.N; i++ {
478-
_, err := conn.Execute("SELECT NAME0,NAME1,NAME2 FROM SQL_TEST WHERE NAME0=?", []interface{}{uint(1111)})
479-
if err != nil {
480-
b.Errorf("Select failed: %s", err.Error())
481-
break
482-
}
483-
}
484-
}
485-
486486
///////////////////
487487

488488
func TestClient(t *testing.T) {

0 commit comments

Comments
 (0)