diff --git a/benchmarks_test.go b/benchmarks_test.go index e591437e..5c5163d9 100644 --- a/benchmarks_test.go +++ b/benchmarks_test.go @@ -154,7 +154,7 @@ func runRequest(B *testing.B, r *Engine, method, path string) { w := newMockWriter() B.ReportAllocs() B.ResetTimer() - for range B.N { + for B.Loop() { r.ServeHTTP(w, req) } } diff --git a/binding/default_validator_benchmark_test.go b/binding/default_validator_benchmark_test.go index 5732204d..37109bc7 100644 --- a/binding/default_validator_benchmark_test.go +++ b/binding/default_validator_benchmark_test.go @@ -20,7 +20,7 @@ func BenchmarkSliceValidationError(b *testing.B) { b.ReportAllocs() b.ResetTimer() - for range b.N { + for b.Loop() { if len(e.Error()) == 0 { b.Errorf("error") } diff --git a/binding/form_mapping_benchmark_test.go b/binding/form_mapping_benchmark_test.go index f5c970a6..d40699e9 100644 --- a/binding/form_mapping_benchmark_test.go +++ b/binding/form_mapping_benchmark_test.go @@ -31,7 +31,7 @@ type structFull struct { func BenchmarkMapFormFull(b *testing.B) { var s structFull - for range b.N { + for b.Loop() { err := mapForm(&s, form) if err != nil { b.Fatalf("Error on a form mapping") @@ -54,7 +54,7 @@ type structName struct { func BenchmarkMapFormName(b *testing.B) { var s structName - for range b.N { + for b.Loop() { err := mapForm(&s, form) if err != nil { b.Fatalf("Error on a form mapping") diff --git a/context_test.go b/context_test.go index 33d143d2..d52ad044 100644 --- a/context_test.go +++ b/context_test.go @@ -3632,7 +3632,7 @@ func BenchmarkGetMapFromFormData(b *testing.B) { for _, bm := range benchmarks { b.Run(bm.name, func(b *testing.B) { b.ReportAllocs() - for range b.N { + for b.Loop() { _, _ = getMapFromFormData(bm.data, bm.key) } }) diff --git a/internal/bytesconv/bytesconv_test.go b/internal/bytesconv/bytesconv_test.go index 97882c35..9fe63e8c 100644 --- a/internal/bytesconv/bytesconv_test.go +++ b/internal/bytesconv/bytesconv_test.go @@ -81,25 +81,25 @@ func TestStringToBytes(t *testing.T) { // go test -v -run=none -bench=^BenchmarkBytesConv -benchmem=true func BenchmarkBytesConvBytesToStrRaw(b *testing.B) { - for range b.N { + for b.Loop() { rawBytesToStr(testBytes) } } func BenchmarkBytesConvBytesToStr(b *testing.B) { - for range b.N { + for b.Loop() { BytesToString(testBytes) } } func BenchmarkBytesConvStrToBytesRaw(b *testing.B) { - for range b.N { + for b.Loop() { rawStrToBytes(testString) } } func BenchmarkBytesConvStrToBytes(b *testing.B) { - for range b.N { + for b.Loop() { StringToBytes(testString) } } diff --git a/path_test.go b/path_test.go index eef79408..e1386140 100644 --- a/path_test.go +++ b/path_test.go @@ -94,7 +94,7 @@ func TestPathCleanMallocs(t *testing.T) { func BenchmarkPathClean(b *testing.B) { b.ReportAllocs() - for range b.N { + for { for _, test := range cleanTests { cleanPath(test.path) } @@ -137,7 +137,7 @@ func BenchmarkPathCleanLong(b *testing.B) { b.ResetTimer() b.ReportAllocs() - for range b.N { + for b.Loop() { for _, test := range cleanTests { cleanPath(test.path) } diff --git a/utils_test.go b/utils_test.go index b8e6571a..8bcf00e4 100644 --- a/utils_test.go +++ b/utils_test.go @@ -19,7 +19,7 @@ func init() { } func BenchmarkParseAccept(b *testing.B) { - for range b.N { + for b.Loop() { parseAccept("text/html , application/xhtml+xml,application/xml;q=0.9, */* ;q=0.8") } }