diff --git a/format_test.go b/format_test.go index b878637..d25933c 100644 --- a/format_test.go +++ b/format_test.go @@ -152,14 +152,14 @@ func Benchmark_FormatUint(b *testing.B) { for _, input := range inputs { b.Run(input.name+"/fiber", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = FormatUint(input.value) + for b.Loop() { + FormatUint(input.value) } }) b.Run(input.name+"/strconv", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = strconv.FormatUint(input.value, 10) + for b.Loop() { + strconv.FormatUint(input.value, 10) } }) } @@ -181,14 +181,14 @@ func Benchmark_FormatInt(b *testing.B) { for _, input := range inputs { b.Run(input.name+"/fiber", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = FormatInt(input.value) + for b.Loop() { + FormatInt(input.value) } }) b.Run(input.name+"/strconv", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = strconv.FormatInt(input.value, 10) + for b.Loop() { + strconv.FormatInt(input.value, 10) } }) } @@ -199,14 +199,14 @@ func Benchmark_FormatUint32(b *testing.B) { b.Run("fiber", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = FormatUint32(input) + for b.Loop() { + FormatUint32(input) } }) b.Run("strconv", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = strconv.FormatUint(uint64(input), 10) + for b.Loop() { + strconv.FormatUint(uint64(input), 10) } }) } @@ -216,14 +216,14 @@ func Benchmark_FormatInt32(b *testing.B) { b.Run("fiber", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = FormatInt32(input) + for b.Loop() { + FormatInt32(input) } }) b.Run("strconv", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = strconv.FormatInt(int64(input), 10) + for b.Loop() { + strconv.FormatInt(int64(input), 10) } }) } @@ -233,14 +233,14 @@ func Benchmark_FormatUint16(b *testing.B) { b.Run("fiber", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = FormatUint16(input) + for b.Loop() { + FormatUint16(input) } }) b.Run("strconv", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = strconv.FormatUint(uint64(input), 10) + for b.Loop() { + strconv.FormatUint(uint64(input), 10) } }) } @@ -250,14 +250,14 @@ func Benchmark_FormatInt16(b *testing.B) { b.Run("fiber", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = FormatInt16(input) + for b.Loop() { + FormatInt16(input) } }) b.Run("strconv", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = strconv.FormatInt(int64(input), 10) + for b.Loop() { + strconv.FormatInt(int64(input), 10) } }) } @@ -267,14 +267,14 @@ func Benchmark_FormatUint8(b *testing.B) { b.Run("fiber", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = FormatUint8(input) + for b.Loop() { + FormatUint8(input) } }) b.Run("strconv", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = strconv.FormatUint(uint64(input), 10) + for b.Loop() { + strconv.FormatUint(uint64(input), 10) } }) } @@ -284,14 +284,14 @@ func Benchmark_FormatInt8(b *testing.B) { b.Run("fiber", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = FormatInt8(input) + for b.Loop() { + FormatInt8(input) } }) b.Run("strconv", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = strconv.FormatInt(int64(input), 10) + for b.Loop() { + strconv.FormatInt(int64(input), 10) } }) } @@ -302,14 +302,14 @@ func Benchmark_AppendUint(b *testing.B) { b.Run("fiber", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = AppendUint(dst, input) + for b.Loop() { + AppendUint(dst, input) } }) b.Run("strconv", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = strconv.AppendUint(dst, input, 10) + for b.Loop() { + strconv.AppendUint(dst, input, 10) } }) } @@ -327,14 +327,14 @@ func Benchmark_AppendInt(b *testing.B) { for _, input := range inputs { b.Run(input.name+"/fiber", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = AppendInt(dst, input.value) + for b.Loop() { + AppendInt(dst, input.value) } }) b.Run(input.name+"/strconv", func(b *testing.B) { b.ReportAllocs() - for i := 0; i < b.N; i++ { - _ = strconv.AppendInt(dst, input.value, 10) + for b.Loop() { + strconv.AppendInt(dst, input.value, 10) } }) }