Skip to content

Commit df1fb6a

Browse files
craig[bot]herkolategan
andcommitted
Merge #151391
151391: sql/sqlstats/sslocal: fix BenchmarkSqlStatsDrain r=dhartunian a=herkolategan Previously, this benchmark would reset the timer during the internal iteration loop `b.N`. This causes the internal go benchmark heuristics that try to achieve a running time of 1 second to never reach its goal, ultimately causing a timeout. This change fixes the issue by rather using Start / Stop Timer to account for creating and populating stats. Fixes: #151304 Epic: None Release note: None Co-authored-by: Herko Lategan <[email protected]>
2 parents 6ccd99f + 229b266 commit df1fb6a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/sql/sqlstats/sslocal/sql_stats_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,12 +2053,12 @@ func BenchmarkSqlStatsDrain(b *testing.B) {
20532053
for _, bc := range benchCase {
20542054
b.Run(fmt.Sprintf("drainsql-%d", bc.statsCount), func(b *testing.B) {
20552055
for i := 0; i < b.N; i++ {
2056+
b.StopTimer()
20562057
sqlStats := createNewSqlStats()
20572058
populateSqlStats(b, sqlStats, bc.statsCount)
2058-
b.ResetTimer()
2059+
b.StartTimer()
20592060
sqlStats.DrainStats(ctx)
20602061
}
2061-
20622062
})
20632063
}
20642064
}

0 commit comments

Comments
 (0)