From 9c0bea3dfa885ed270a6c64cfdcc08ae6d81a128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Sun, 21 Jul 2024 18:28:00 +0200 Subject: [PATCH] Add AppendInt function with positive/negative number convertion to string Benchmark_ItoA/fiber (pos_num)-12 190428255 6.13 ns/op 0 B/op 0 allocs/op Benchmark_ItoA/fiber (pos_num)-12 196626811 6.08 ns/op 0 B/op 0 allocs/op Benchmark_ItoA/strconv.Itoa (pos_num)-12 80716807 14.33 ns/op 4 B/op 1 allocs/op Benchmark_ItoA/strconv.Itoa (pos_num)-12 80445802 14.30 ns/op 4 B/op 1 allocs/op Benchmark_ItoA/strconv.FormatInt_(pos_num)-12 81137728 14.30 ns/op 4 B/op 1 allocs/op Benchmark_ItoA/strconv.FormatInt_(pos_num)-12 81345360 14.49 ns/op 4 B/op 1 allocs/op Benchmark_ItoA/fiber (neg_num)-12 151121002 7.81 ns/op 0 B/op 0 allocs/op Benchmark_ItoA/fiber (neg_num)-12 153566410 7.70 ns/op 0 B/op 0 allocs/op Benchmark_ItoA/strconv.Itoa (neg_num)-12 84505304 13.75 ns/op 5 B/op 1 allocs/op Benchmark_ItoA/strconv.Itoa (neg_num)-12 82524801 13.76 ns/op 5 B/op 1 allocs/op Benchmark_ItoA/strconv.FormatInt (neg_num)-12 84884136 13.88 ns/op 5 B/op 1 allocs/op Benchmark_ItoA/strconv.FormatInt (neg_num)-12 85829492 13.76 ns/op 5 B/op 1 allocs/op --- convert_test.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/convert_test.go b/convert_test.go index 256480f..60f01f2 100644 --- a/convert_test.go +++ b/convert_test.go @@ -259,19 +259,6 @@ func Benchmark_ToString(b *testing.B) { } } -func Benchmark_ToString_string(b *testing.B) { - res := "" - expectedRes := "4242" - b.ReportAllocs() - b.ResetTimer() - - for i := 0; i < b.N; i++ { - res = ToString(4242) - } - - require.Equal(b, expectedRes, res) -} - // go test -v -run=^$ -bench=ToString_concurrency -benchmem -count=4 func Benchmark_ToString_concurrency(b *testing.B) { for _, value := range dataTypeExamples {