]> Cypherpunks repositories - gostls13.git/commit
fmt: speed up 10-20%
authorRob Pike <r@golang.org>
Tue, 29 May 2012 22:08:08 +0000 (15:08 -0700)
committerRob Pike <r@golang.org>
Tue, 29 May 2012 22:08:08 +0000 (15:08 -0700)
commit53bc19442d570802c0966d9b0c623151e78e5875
tree2c6b71fffbe0bec2f95c45186f0db525f1e6b12c
parentd61707f49053d13afb7c9bfdb7981aeff94a9c62
fmt: speed up 10-20%

The check for Stringer etc. can only fire if the test is not a builtin, so avoid
the expensive check if we know there's no chance.
Also put in a fast path for pad, which saves a more modest amount.

benchmark                      old ns/op    new ns/op    delta
BenchmarkSprintfEmpty                148          152   +2.70%
BenchmarkSprintfString               585          497  -15.04%
BenchmarkSprintfInt                  441          396  -10.20%
BenchmarkSprintfIntInt               718          603  -16.02%
BenchmarkSprintfPrefixedInt          676          621   -8.14%
BenchmarkSprintfFloat               1003          953   -4.99%
BenchmarkManyArgs                   2945         2312  -21.49%
BenchmarkScanInts                1704152      1734441   +1.78%
BenchmarkScanRecursiveInt        1837397      1828920   -0.46%

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6245068
src/pkg/fmt/fmt_test.go
src/pkg/fmt/format.go
src/pkg/fmt/print.go