Stupid text formatting performance question

Is there any real performance difference between doing
myStr := strconv.Itoa(42);fmt.Println(myStr)
fmt.Println(fmt.Sprintf("%d",42)? That’s it. Simple, stupid question.

I’d guess that Sprintf is slower because it has to parse the format string("%d").

1 Like

Here is a benchmark test about your question:

Anyway you can benchmark your code with golang :smiley: