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

Function BenchmarkMinimalPreparedSelectBaseline

pgxpool/bench_test.go:27–55  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

25}
26
27func BenchmarkMinimalPreparedSelectBaseline(b *testing.B) {
28 config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
29 require.NoError(b, err)
30
31 config.AfterConnect = func(ctx context.Context, c *pgx.Conn) error {
32 _, err := c.Prepare(ctx, "ps1", "select $1::int8")
33 return err
34 }
35
36 db, err := pgxpool.NewWithConfig(context.Background(), config)
37 require.NoError(b, err)
38
39 conn, err := db.Acquire(context.Background())
40 require.NoError(b, err)
41 defer conn.Release()
42
43 var n int64
44
45 for i := 0; b.Loop(); i++ {
46 err = conn.QueryRow(context.Background(), "ps1", i).Scan(&n)
47 if err != nil {
48 b.Fatal(err)
49 }
50
51 if n != int64(i) {
52 b.Fatalf("expected %d, got %d", i, n)
53 }
54 }
55}
56
57func BenchmarkMinimalPreparedSelect(b *testing.B) {
58 config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))

Callers

nothing calls this directly

Calls 7

ParseConfigFunction · 0.92
NewWithConfigFunction · 0.92
AcquireMethod · 0.80
ReleaseMethod · 0.80
PrepareMethod · 0.65
ScanMethod · 0.65
QueryRowMethod · 0.65

Tested by

no test coverage detected