MCPcopy
hub / github.com/jackc/pgx / BenchmarkMinimalPgConnPreparedStatementDescriptionSelect

Function BenchmarkMinimalPgConnPreparedStatementDescriptionSelect

bench_test.go:161–194  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

159}
160
161func BenchmarkMinimalPgConnPreparedStatementDescriptionSelect(b *testing.B) {
162 conn := mustConnect(b, mustParseConfig(b, os.Getenv("PGX_TEST_DATABASE")))
163 defer closeConn(b, conn)
164
165 pgConn := conn.PgConn()
166
167 psd, err := pgConn.Prepare(context.Background(), "ps1", "select $1::int8", nil)
168 if err != nil {
169 b.Fatal(err)
170 }
171
172 encodedBytes := make([]byte, 8)
173
174 b.ResetTimer()
175 for i := 0; i < b.N; i++ {
176
177 rr := pgConn.ExecStatement(context.Background(), psd, [][]byte{encodedBytes}, []int16{1}, []int16{1})
178 if err != nil {
179 b.Fatal(err)
180 }
181
182 for rr.NextRow() {
183 for i := range rr.Values() {
184 if !bytes.Equal(rr.Values()[0], encodedBytes) {
185 b.Fatalf("unexpected values: %s %s", rr.Values()[i], encodedBytes)
186 }
187 }
188 }
189 _, err = rr.Close()
190 if err != nil {
191 b.Fatal(err)
192 }
193 }
194}
195
196func BenchmarkPointerPointerWithNullValues(b *testing.B) {
197 conn := mustConnect(b, mustParseConfig(b, os.Getenv("PGX_TEST_DATABASE")))

Callers

nothing calls this directly

Calls 9

PgConnMethod · 0.80
NextRowMethod · 0.80
mustConnectFunction · 0.70
mustParseConfigFunction · 0.70
closeConnFunction · 0.70
PrepareMethod · 0.65
ValuesMethod · 0.65
CloseMethod · 0.65
ExecStatementMethod · 0.45

Tested by

no test coverage detected