MCPcopy Create free account
hub / github.com/efectn/go-orm-benchmarks / ReadSlice

Method ReadSlice

bench/pgx_pool.go:122–163  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

120}
121
122func (pgx *PgxPool) ReadSlice(b *testing.B) {
123 m := NewModel()
124 for i := 0; i < 100; i++ {
125 _, err := pgx.conn.Exec(ctx, sqlxInsertSQL, m.Name, m.Title, m.Fax, m.Web, m.Age, m.Right, m.Counter)
126 if err != nil {
127 helper.SetError(b, pgx.Name(), "ReadSlice", err.Error())
128 }
129 }
130
131 b.ReportAllocs()
132 b.ResetTimer()
133
134 for i := 0; i < b.N; i++ {
135 ms := make([]Model, 100)
136 rows, err := pgx.conn.Query(ctx, sqlxSelectMultiSQL)
137 if err != nil {
138 helper.SetError(b, pgx.Name(), "ReadSlice", err.Error())
139 }
140
141 for j := 0; rows.Next() && j < len(ms); j++ {
142 err = rows.Scan(
143 &ms[j].Id,
144 &ms[j].Name,
145 &ms[j].Title,
146 &ms[j].Fax,
147 &ms[j].Web,
148 &ms[j].Age,
149 &ms[j].Right,
150 &ms[j].Counter,
151 )
152 if err != nil {
153 helper.SetError(b, pgx.Name(), "ReadSlice", err.Error())
154 }
155 }
156 err = rows.Err()
157 if err != nil {
158 helper.SetError(b, pgx.Name(), "ReadSlice", err.Error())
159 }
160
161 rows.Close()
162 }
163}

Callers

nothing calls this directly

Calls 8

NameMethod · 0.95
SetErrorFunction · 0.92
NewModelFunction · 0.85
ErrorMethod · 0.65
CloseMethod · 0.65
ExecMethod · 0.45
QueryMethod · 0.45
ScanMethod · 0.45

Tested by

no test coverage detected