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

Function BenchmarkSelectRowsScanSimple

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

Source from the content-addressed store, hash-verified

972}
973
974func BenchmarkSelectRowsScanSimple(b *testing.B) {
975 conn := mustConnectString(b, os.Getenv("PGX_TEST_DATABASE"))
976 defer closeConn(b, conn)
977
978 rowCounts := getSelectRowsCounts(b)
979
980 for _, rowCount := range rowCounts {
981 b.Run(fmt.Sprintf("%d rows", rowCount), func(b *testing.B) {
982 br := &BenchRowSimple{}
983 for b.Loop() {
984 rows, err := conn.Query(context.Background(), "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 + $1) n", rowCount)
985 if err != nil {
986 b.Fatal(err)
987 }
988
989 for rows.Next() {
990 rows.Scan(&br.ID, &br.FirstName, &br.LastName, &br.Sex, &br.BirthDate, &br.Weight, &br.Height, &br.Tags, &br.UpdateTime)
991 }
992
993 if rows.Err() != nil {
994 b.Fatal(rows.Err())
995 }
996 }
997 })
998 }
999}
1000
1001type BenchRowStringBytes struct {
1002 ID int32

Callers

nothing calls this directly

Calls 8

mustConnectStringFunction · 0.85
closeConnFunction · 0.70
getSelectRowsCountsFunction · 0.70
QueryMethod · 0.65
NextMethod · 0.65
ScanMethod · 0.65
ErrMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected