mirror of https://github.com/jackc/pgx.git
Add benchmark of ConnectionPool Acquire/Release
parent
e55a5ebccf
commit
7450854d50
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue