all: Fix some benchmarks broken by modernize

It's not possible to use `b.Loop()` when `b.N` is used to prepare test data.

See 264022a75a
See #14107
This commit is contained in:
Bjørn Erik Pedersen
2025-11-06 10:43:12 +01:00
parent 04650ce778
commit 91eac9e573
16 changed files with 24 additions and 26 deletions
+1 -1
View File
@@ -161,7 +161,7 @@ func BenchmarkIsContextType(b *testing.B) {
}
b.ResetTimer()
for i := 0; b.Loop(); i++ {
for i := 0; i < b.N; i++ {
if !IsContextType(ctxs[i]) {
b.Fatal("not context")
}
+2 -2
View File
@@ -105,13 +105,13 @@ func BenchmarkUniqueStrings(b *testing.B) {
b.Run("Reuse slice sorted", func(b *testing.B) {
b.StopTimer()
inputs := make([][]string, b.N)
for i := 0; b.Loop(); i++ {
for i := 0; i < b.N; i++ {
inputc := make([]string, len(input))
copy(inputc, input)
inputs[i] = inputc
}
b.StartTimer()
for i := 0; b.Loop(); i++ {
for i := 0; i < b.N; i++ {
inputc := inputs[i]
result := UniqueStringsSorted(inputc)