Closed agnivade closed 7 years ago
Benchmarks show clear improvement -
func BenchmarkStringSprintf(b *testing.B) { w1 := "hello" w2 := "world" w3 := "fd" for n := 0; n < b.N; n++ { fmt.Sprintf("%s%s:%s", w1, w2, w3) } } func BenchmarkStringConcat(b *testing.B) { w1 := "hello" w2 := "world" w3 := "fd" for n := 0; n < b.N; n++ { _ = w1 + w2 + ":" + w3 } }
BenchmarkStringSprintf-4 5000000 338 ns/op 64 B/op 4 allocs/op BenchmarkStringConcat-4 30000000 40.3 ns/op 0 B/op 0 allocs/op PASS ok stdtest 3.303s
Hi @quipo - Any updates on this ? Thanks.
Thanks @agnivade!
Benchmarks show clear improvement -