use testing.B.Loop in all benchmark tests (#5285)

go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -category=bloop -fix -test ./...
was used as a starting point.
This commit is contained in:
Marten Seemann
2025-08-16 12:44:56 +02:00
committed by GitHub
parent 66e5c5ebaa
commit 8c062ae604
13 changed files with 108 additions and 86 deletions

View File

@@ -31,8 +31,7 @@ func BenchmarkHandshake(b *testing.B) {
tr := &quic.Transport{Conn: newUDPConnLocalhost(b)}
defer tr.Close()
b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
c, err := tr.Dial(context.Background(), ln.Addr(), tlsClientConfig, nil)
require.NoError(b, err)
serverConn := <-connChan
@@ -68,8 +67,7 @@ func BenchmarkStreamChurn(b *testing.B) {
}
}()
b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
str, err := conn.OpenStreamSync(context.Background())
require.NoError(b, err)
require.NoError(b, str.Close())