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

Function BenchmarkMinimalPreparedSelect

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

Source from the content-addressed store, hash-verified

102}
103
104func BenchmarkMinimalPreparedSelect(b *testing.B) {
105 conn := mustConnect(b, mustParseConfig(b, os.Getenv("PGX_TEST_DATABASE")))
106 defer closeConn(b, conn)
107
108 _, err := conn.Prepare(context.Background(), "ps1", "select $1::int8")
109 if err != nil {
110 b.Fatal(err)
111 }
112
113 var n int64
114
115 for i := 0; b.Loop(); i++ {
116 err = conn.QueryRow(context.Background(), "ps1", i).Scan(&n)
117 if err != nil {
118 b.Fatal(err)
119 }
120
121 if n != int64(i) {
122 b.Fatalf("expected %d, got %d", i, n)
123 }
124 }
125}
126
127func BenchmarkMinimalPgConnPreparedSelect(b *testing.B) {
128 conn := mustConnect(b, mustParseConfig(b, os.Getenv("PGX_TEST_DATABASE")))

Callers

nothing calls this directly

Calls 6

mustConnectFunction · 0.70
mustParseConfigFunction · 0.70
closeConnFunction · 0.70
PrepareMethod · 0.65
ScanMethod · 0.65
QueryRowMethod · 0.65

Tested by

no test coverage detected