Go语言整数值转字符串的效率问题
文章目录 参考 Go in Action 标准库提供了三种方法可以将整数值转为字符串。 fmt.Sprintf strconv.FormatInt strconv.Itoa 运行下面的代码,可以得到三种方法的基础测试结果。 package test import ( fmt strconv testing ) func BenchmarkSprintf(b *testing.B) { number := 10 b.ResetTimer() for i := 0; i < b.N; i++ { fmt.Sprintf(%d, number) } } func B
下载地址
用户评论