File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,29 @@ func BenchmarkIntFormatting(b *testing.B) {
103
103
})
104
104
}
105
105
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
+
106
129
func BenchmarkUintFormatting (b * testing.B ) {
107
130
b .Run ("fmt.Sprint" , func (b * testing.B ) {
108
131
for n := 0 ; n < b .N ; n ++ {
You can’t perform that action at this time.
0 commit comments