(b *testing.B, db *sql.DB, p int)
| 295 | } |
| 296 | |
| 297 | func 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 | |
| 318 | func BenchmarkExecContext(b *testing.B) { |
| 319 | db := initDB(b, false, |
no test coverage detected