Add benchmark of ConnectionPool Acquire/Release

pgx-vs-pq
Jack Christensen 2013-07-25 07:34:38 -05:00
parent e55a5ebccf
commit 7450854d50
1 changed files with 16 additions and 0 deletions

View File

@ -599,3 +599,19 @@ func BenchmarkTimestampTzBinary(b *testing.B) {
mustSelectRows(b, conn, "selectTimestampTz")
}
}
func BenchmarkConnectionPool(b *testing.B) {
options := pgx.ConnectionPoolOptions{MaxConnections: 5}
pool, err := pgx.NewConnectionPool(*defaultConnectionParameters, options)
if err != nil {
b.Fatalf("Unable to create connection pool: %v", err)
}
defer pool.Close()
b.ResetTimer()
for i := 0; i < b.N; i++ {
conn := pool.Acquire()
pool.Release(conn)
}
}