Stupid text formatting performance question

Is there any real performance difference between doing
myStr := strconv.Itoa(42);fmt.Println(myStr)
and
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").

2 Likes

Here is a benchmark test about your question:

Anyway you can benchmark your code with golang :smiley:

1 Like

Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.