Skip to content

Commit 95e85ce

Browse files
committed
connection pool benchmarks
1 parent c04e2e4 commit 95e85ce

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ test:
66
rm -f cover.out; true
77
rm -rf ${GOPATH}/src/gopkg.in/rethinkdb/rethinkdb-go.v6
88
test -d ${GOPATH}/src/gopkg.in/rethinkdb/rethinkdb-go.v6.bak && mv ${GOPATH}/src/gopkg.in/rethinkdb/rethinkdb-go.v6.bak ${GOPATH}/src/gopkg.in/rethinkdb/rethinkdb-go.v6; true
9+
10+
benchpool:
11+
go test -v -cpu 1,2,4,8,16,24,32,64,128,256 -bench=BenchmarkConnectionPool -run ^$ ./internal/integration/tests/

internal/integration/tests/benchmarks_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,62 @@ import (
99
"time"
1010
)
1111

12+
func BenchmarkConnectionPoolLightweightQuery_Single(b *testing.B) {
13+
q := r.Random()
14+
15+
for i := 0; i < b.N; i++ {
16+
var num float64
17+
err := q.ReadOne(&num, session)
18+
if err != nil {
19+
b.Errorf("read random number failed: %v", err)
20+
}
21+
}
22+
}
23+
24+
func BenchmarkConnectionPoolLightweightQuery_Parallel(b *testing.B) {
25+
q := r.Random()
26+
27+
b.RunParallel(func(pb *testing.PB) {
28+
for pb.Next() {
29+
var num float64
30+
err := q.ReadOne(&num, session)
31+
if err != nil {
32+
b.Errorf("read random number failed: %v", err)
33+
}
34+
}
35+
})
36+
}
37+
38+
func BenchmarkConnectionPoolLightweightQuery_Parallel3X(b *testing.B) {
39+
q := r.Random()
40+
41+
b.SetParallelism(3)
42+
b.RunParallel(func(pb *testing.PB) {
43+
for pb.Next() {
44+
var num float64
45+
err := q.ReadOne(&num, session)
46+
if err != nil {
47+
b.Errorf("read random number failed: %v", err)
48+
}
49+
}
50+
})
51+
}
52+
53+
func BenchmarkConnectionPoolLightweightQuery_Parallel10X(b *testing.B) {
54+
q := r.Random()
55+
56+
b.SetParallelism(10)
57+
b.RunParallel(func(pb *testing.PB) {
58+
for pb.Next() {
59+
var num float64
60+
err := q.ReadOne(&num, session)
61+
if err != nil {
62+
b.Errorf("read random number failed: %v", err)
63+
}
64+
}
65+
})
66+
}
67+
1268
func BenchmarkBatch200RandomWrites(b *testing.B) {
1369

1470
var term r.Term

0 commit comments

Comments
 (0)