MCPcopy Create free account
hub / github.com/go-pg/pg / BenchmarkQueryRowStmtScan

Function BenchmarkQueryRowStmtScan

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

Source from the content-addressed store, hash-verified

253}
254
255func BenchmarkQueryRowStmtScan(b *testing.B) {
256 db := benchmarkDB()
257 defer db.Close()
258
259 stmt, err := db.Prepare(`SELECT $1::bigint AS num`)
260 if err != nil {
261 b.Fatal(err)
262 }
263 defer stmt.Close()
264
265 b.ResetTimer()
266
267 for i := 0; i < b.N; i++ {
268 var n int64
269 _, err := stmt.QueryOne(pg.Scan(&n), 1)
270 if err != nil {
271 b.Fatal(err)
272 }
273 if n != 1 {
274 b.Fatalf("got %d, wanted 1", n)
275 }
276 }
277}
278
279func BenchmarkExec(b *testing.B) {
280 db := benchmarkDB()

Callers

nothing calls this directly

Calls 5

benchmarkDBFunction · 0.85
CloseMethod · 0.65
QueryOneMethod · 0.65
PrepareMethod · 0.45
ScanMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…