Skip to content

Commit 943e3b4

Browse files
committed
benchmark: adds int with conversion
1 parent 18f8706 commit 943e3b4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

analyzer/replacements_bench_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,29 @@ func BenchmarkIntFormatting(b *testing.B) {
103103
})
104104
}
105105

106+
func BenchmarkIntConversionFormatting(b *testing.B) {
107+
b.Run("fmt.Sprint", func(b *testing.B) {
108+
u := int32(0x12345678)
109+
for n := 0; n < b.N; n++ {
110+
_ = fmt.Sprint(u)
111+
}
112+
})
113+
114+
b.Run("fmt.Sprintf", func(b *testing.B) {
115+
u := int32(0x12345678)
116+
for n := 0; n < b.N; n++ {
117+
_ = fmt.Sprintf("%d", u)
118+
}
119+
})
120+
121+
b.Run("strconv.FormatInt", func(b *testing.B) {
122+
u := int32(0x12345678)
123+
for n := 0; n < b.N; n++ {
124+
_ = strconv.FormatInt(int64(u), 10)
125+
}
126+
})
127+
}
128+
106129
func BenchmarkUintFormatting(b *testing.B) {
107130
b.Run("fmt.Sprint", func(b *testing.B) {
108131
for n := 0; n < b.N; n++ {

0 commit comments

Comments
 (0)