From 2818e268a8bf087ae8ee329571fa428b9381ea1c Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Tue, 1 Jan 2019 14:17:17 -0600 Subject: [PATCH] Add non-buffered benchmark --- pgconn/benchmark_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pgconn/benchmark_test.go b/pgconn/benchmark_test.go index da5bd4fc..aff21216 100644 --- a/pgconn/benchmark_test.go +++ b/pgconn/benchmark_test.go @@ -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) + } + } +}