Add non-buffered benchmark

pull/483/head
Jack Christensen 2019-01-01 14:17:17 -06:00
parent 96680d6489
commit 2818e268a8
1 changed files with 21 additions and 0 deletions

View File

@ -50,3 +50,24 @@ func BenchmarkExecPrepared(b *testing.B) {
require.Nil(b, err)
}
}
func BenchmarkSendExecPrepared(b *testing.B) {
conn, err := pgconn.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
require.Nil(b, err)
defer closeConn(b, conn)
err = conn.Prepare(context.Background(), "ps1", "select 'hello'::text as a, 42::int4 as b, '2019-01-01'::date", nil)
b.ResetTimer()
for i := 0; i < b.N; i++ {
conn.SendExecPrepared("ps1", nil, nil, nil)
err := conn.Flush(context.Background())
require.Nil(b, err)
for conn.NextResult(context.Background()) {
_, err := conn.ResultReader().Close()
require.Nil(b, err)
}
}
}