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

Function BenchmarkSelectRowsPgConnExecText

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

Source from the content-addressed store, hash-verified

1093}
1094
1095func BenchmarkSelectRowsPgConnExecText(b *testing.B) {
1096 conn := mustConnectString(b, os.Getenv("PGX_TEST_DATABASE"))
1097 defer closeConn(b, conn)
1098
1099 rowCounts := getSelectRowsCounts(b)
1100
1101 for _, rowCount := range rowCounts {
1102 b.Run(fmt.Sprintf("%d rows", rowCount), func(b *testing.B) {
1103 for b.Loop() {
1104 mrr := conn.PgConn().Exec(context.Background(), fmt.Sprintf("select n, 'Adam', 'Smith ' || n, 'male', '1952-06-16'::date, 258, 72, '{foo,bar,baz}'::text[], '2001-01-28 01:02:03-05'::timestamptz from generate_series(100001, 100000 + %d) n", rowCount))
1105 for mrr.NextResult() {
1106 rr := mrr.ResultReader()
1107 for rr.NextRow() {
1108 rr.Values()
1109 }
1110 }
1111
1112 err := mrr.Close()
1113 if err != nil {
1114 b.Fatal(err)
1115 }
1116 }
1117 })
1118 }
1119}
1120
1121func BenchmarkSelectRowsPgConnExecParams(b *testing.B) {
1122 conn := mustConnectString(b, os.Getenv("PGX_TEST_DATABASE"))

Callers

nothing calls this directly

Calls 11

mustConnectStringFunction · 0.85
PgConnMethod · 0.80
NextResultMethod · 0.80
ResultReaderMethod · 0.80
NextRowMethod · 0.80
closeConnFunction · 0.70
getSelectRowsCountsFunction · 0.70
ExecMethod · 0.65
ValuesMethod · 0.65
CloseMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected