MCPcopy
hub / github.com/go-sql-driver/mysql / benchmarkExecContext

Function benchmarkExecContext

benchmark_test.go:297–316  ·  view source on GitHub ↗
(b *testing.B, db *sql.DB, p int)

Source from the content-addressed store, hash-verified

295}
296
297func benchmarkExecContext(b *testing.B, db *sql.DB, p int) {
298 ctx, cancel := context.WithCancel(context.Background())
299 defer cancel()
300 db.SetMaxIdleConns(p * runtime.GOMAXPROCS(0))
301
302 tb := (*TB)(b)
303 stmt := tb.checkStmt(db.PrepareContext(ctx, "DO 1"))
304 defer stmt.Close()
305
306 b.SetParallelism(p)
307 b.ReportAllocs()
308 b.ResetTimer()
309 b.RunParallel(func(pb *testing.PB) {
310 for pb.Next() {
311 if _, err := stmt.ExecContext(ctx); err != nil {
312 b.Fatal(err)
313 }
314 }
315 })
316}
317
318func BenchmarkExecContext(b *testing.B) {
319 db := initDB(b, false,

Callers 1

BenchmarkExecContextFunction · 0.85

Calls 5

checkStmtMethod · 0.80
PrepareContextMethod · 0.80
CloseMethod · 0.45
NextMethod · 0.45
ExecContextMethod · 0.45

Tested by

no test coverage detected