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

@@ -878,6 +878,8 @@ func BenchmarkTransportParameters(b *testing.B) {
}
func benchmarkTransportParameters(b *testing.B, withPreferredAddress bool) {
b.ReportAllocs()
var token protocol.StatelessResetToken
rand.Read(token[:])
rcid := protocol.ParseConnectionID([]byte{0xde, 0xad, 0xc0, 0xde})
@@ -915,10 +917,8 @@ func benchmarkTransportParameters(b *testing.B, withPreferredAddress bool) {
}
data := params.Marshal(protocol.PerspectiveServer)
b.ResetTimer()
b.ReportAllocs()
var p TransportParameters
for i := 0; i < b.N; i++ {
for b.Loop() {
if err := p.Unmarshal(data, protocol.PerspectiveServer); err != nil {
b.Fatal(err)
}