go test -test.bench "FormatInt"
PASS
BenchmarkFormatInt 200000 7852 ns/op
ok strconv 2.636s
My tests (code at http://play.golang.org/p/YF76ATMk_q) show Sprint and Sprintf to have roughly equivalent speeds, with FormatInt being ~3.5x faster than fmt offerings, and AppendInt ~2x faster than FormatInt. All of these figures should be considered only in the context of running these functions in a tight loop; used in most other contexts, the difference between the slowest and fastest would be entirely negligible.
On Mar 5, 2013 8:59 PM, "davy zhang" <davy...@gmail.com> wrote:
>
> Very interesting, I am using the release version of go 1.0.3 with mackbookpro i7 2.66Ghz
>
> the result is of BenchmarkRenderTime is way tooooo different :D
>
> I check it on my linux server amazon aws
>
> BenchmarkFmt 1000000 1950 ns/op
> BenchmarkRenderTime 500000 4929 ns/op
> BenchmarkRenderTimeManual 500000 3379 ns/op
> BenchmarkFormatInt 10000000 232 ns/op
> BenchmarkAppendInt 20000000 110 ns/op
> BenchmarkSprint 1000000 6347 ns/op
> BenchmarkSprintf 200000 6493 ns/op
>
> code here :
> http://play.golang.org/p/37ZJIZUKfn
>
> which version of go do you use?
>
>
I bet he uses tip and you shouldn't benchmark on virtual servers like amazon aws. Benchmark on a dedicated machine with next to nothing running for the best results.
> You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/pN1AtedMX3g/unsubscribe?hl=en-US.
> To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.