File tree 1 file changed +23
-25
lines changed
1 file changed +23
-25
lines changed Original file line number Diff line number Diff line change @@ -479,34 +479,32 @@ func BenchmarkReceiveMetadata(b *testing.B) {
479
479
)
480
480
defer db .Close ()
481
481
482
- b .Run ("query" , func (b * testing.B ) {
483
- db .SetMaxIdleConns (0 )
484
- db .SetMaxIdleConns (1 )
485
-
486
- // Create a slice to scan all columns
487
- values := make ([]any , 1000 )
488
- valuePtrs := make ([]any , 1000 )
489
- for j := range values {
490
- valuePtrs [j ] = & values [j ]
491
- }
482
+ db .SetMaxIdleConns (0 )
483
+ db .SetMaxIdleConns (1 )
484
+
485
+ // Create a slice to scan all columns
486
+ values := make ([]any , 1000 )
487
+ valuePtrs := make ([]any , 1000 )
488
+ for j := range values {
489
+ valuePtrs [j ] = & values [j ]
490
+ }
492
491
493
- b .ReportAllocs ()
494
- b .ResetTimer ()
492
+ // Prepare a SELECT query to retrieve metadata
493
+ stmt := tb .checkStmt (db .Prepare ("SELECT * FROM large_integer_table LIMIT 1" ))
494
+ defer stmt .Close ()
495
495
496
- // Prepare a SELECT query to retrieve metadata
497
- stmt := tb .checkStmt (db .Prepare ("SELECT * FROM large_integer_table LIMIT 1" ))
498
- defer stmt .Close ()
496
+ b .ReportAllocs ()
497
+ b .ResetTimer ()
499
498
500
- // Benchmark metadata retrieval
501
- for range b . N {
502
- rows := tb .checkRows (stmt .Query ())
499
+ // Benchmark metadata retrieval
500
+ for b . Loop () {
501
+ rows := tb .checkRows (stmt .Query ())
503
502
504
- rows .Next ()
505
- // Scan the row
506
- err := rows .Scan (valuePtrs ... )
507
- tb .check (err )
503
+ rows .Next ()
504
+ // Scan the row
505
+ err := rows .Scan (valuePtrs ... )
506
+ tb .check (err )
508
507
509
- rows .Close ()
510
- }
511
- })
508
+ rows .Close ()
509
+ }
512
510
}
You can’t perform that action at this time.
0 commit comments