# Prefer strconv over fmt When converting primitives to/from strings, `strconv` is faster than `fmt`.
BadGood
```go for i := 0; i < b.N; i++ { s := fmt.Sprint(rand.Int()) } ``` ```go for i := 0; i < b.N; i++ { s := strconv.Itoa(rand.Int()) } ```
```plain BenchmarkFmtSprint-4 143 ns/op 2 allocs/op ``` ```plain BenchmarkStrconv-4 64.2 ns/op 1 allocs/op ```