1
0
mirror of https://github.com/golang/go synced 2024-10-03 02:31:21 -06:00
go/src
Robert Griesemer faa9d1eca9 strconv: use 64bit uint for decimal conversion if available
The existing code used ints for the (slow) decimal conversion and
assumed that they were 32bit wide.

This change uses uints and the appropriate width (32 or 64bit)
depending on platform.

The performance difference is in the noise for the usual (optimized)
case which does not use the slow path conversion:

benchmark                               old ns/op     new ns/op     delta
BenchmarkFormatFloatDecimal             298           299           +0.34%
BenchmarkFormatFloat                    388           392           +1.03%
BenchmarkFormatFloatExp                 365           364           -0.27%
BenchmarkFormatFloatNegExp              364           362           -0.55%
BenchmarkFormatFloatBig                 482           476           -1.24%
BenchmarkAppendFloatDecimal             100           102           +2.00%
BenchmarkAppendFloat                    199           201           +1.01%
BenchmarkAppendFloatExp                 174           175           +0.57%
BenchmarkAppendFloatNegExp              169           174           +2.96%
BenchmarkAppendFloatBig                 286           286           +0.00%
BenchmarkAppendFloat32Integer           99.9          102           +2.10%
BenchmarkAppendFloat32ExactFraction     161           164           +1.86%
BenchmarkAppendFloat32Point             199           201           +1.01%
BenchmarkAppendFloat32Exp               167           168           +0.60%
BenchmarkAppendFloat32NegExp            163           169           +3.68%
BenchmarkAppendFloat64Fixed1            137           134           -2.19%
BenchmarkAppendFloat64Fixed2            144           146           +1.39%
BenchmarkAppendFloat64Fixed3            138           140           +1.45%
BenchmarkAppendFloat64Fixed4            144           145           +0.69%

The performance difference is significant if the fast path conversion is
explicitly turned off (ftoa.go:101):

benchmark                               old ns/op     new ns/op     delta
BenchmarkFormatFloatDecimal             459           427           -6.97%
BenchmarkFormatFloat                    1560          1180          -24.36%
BenchmarkFormatFloatExp                 5501          3128          -43.14%
BenchmarkFormatFloatNegExp              24085         14360         -40.38%
BenchmarkFormatFloatBig                 1409          1081          -23.28%
BenchmarkAppendFloatDecimal             248           226           -8.87%
BenchmarkAppendFloat                    1315          982           -25.32%
BenchmarkAppendFloatExp                 5274          2869          -45.60%
BenchmarkAppendFloatNegExp              23905         14054         -41.21%
BenchmarkAppendFloatBig                 1194          860           -27.97%
BenchmarkAppendFloat32Integer           167           175           +4.79%
BenchmarkAppendFloat32ExactFraction     182           184           +1.10%
BenchmarkAppendFloat32Point             556           564           +1.44%
BenchmarkAppendFloat32Exp               1134          918           -19.05%
BenchmarkAppendFloat32NegExp            2679          1801          -32.77%
BenchmarkAppendFloat64Fixed1            274           238           -13.14%
BenchmarkAppendFloat64Fixed2            494           368           -25.51%
BenchmarkAppendFloat64Fixed3            1833          1008          -45.01%
BenchmarkAppendFloat64Fixed4            6133          3596          -41.37%

Change-Id: I829b8abcca882b1c10d8ae421d3249597c31f3c9
Reviewed-on: https://go-review.googlesource.com/3811
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-10 17:42:20 +00:00
..
archive all: use "reports whether" in place of "returns true if(f)" 2015-03-18 15:14:06 +00:00
bufio bufio: fix incorrect comment on Scanner.Scan 2015-03-18 00:59:49 +00:00
builtin
bytes bytes, strings: add Reader.Size methods 2015-04-06 08:53:47 +00:00
cmd cmd/internal/gc: clean up Componentgen 2015-04-10 08:16:51 +00:00
compress compress/flate: fix typo in comment 2015-04-01 16:48:04 +00:00
container
crypto crypto/tls: tidy up a little and add test. 2015-04-04 00:06:21 +00:00
database/sql database/sql: Retry with a fresh connection after maxBadConnRetries 2015-04-08 16:18:36 +00:00
debug debug/dwarf, encoding/asn1, go/ast: fix old comments 2015-03-24 00:09:30 +00:00
encoding encoding/gob: more checks for corrupted data 2015-04-09 17:02:19 +00:00
errors
expvar
flag all: use "reports whether" in place of "returns true if(f)" 2015-03-18 15:14:06 +00:00
fmt fmt: improve test coverage of %x and %X format variations for strings 2015-04-01 00:55:30 +00:00
go go/types/internal/gcimporter: update for 7g and 9g 2015-04-08 17:55:51 +00:00
hash os/signal, hash/crc32: add arm64 build tags 2015-03-16 18:46:43 +00:00
html text/template: provide a mechanism for options 2015-04-03 23:40:59 +00:00
image image/jpeg: reject multiple Start-Of-Frame markers. 2015-04-09 02:32:23 +00:00
index/suffixarray
internal runtime: fix tracing of syscall exit 2015-04-10 17:39:06 +00:00
io io: clarify Copy docs regarding error handling 2015-04-08 13:39:33 +00:00
log log: logging an empty string should still print a line 2015-04-09 17:02:27 +00:00
math math/big: better doc strings for ErrNaN functionality 2015-04-09 20:18:32 +00:00
mime mime/quotedprintable: add binary mode to the writer 2015-03-30 12:49:19 +00:00
net net: make multi-IP resolution more flexible. 2015-04-10 09:03:25 +00:00
os os: windows Rename should overwrite destination file. 2015-04-09 08:39:52 +00:00
path all: fix race when allocating buffer for some windows syscalls 2015-04-08 02:06:31 +00:00
reflect runtime, reflect: support multiple moduledata objects 2015-04-10 04:51:42 +00:00
regexp regexp: skip backtracker for long programs 2015-04-09 09:38:23 +00:00
runtime runtime: fix tracing of syscall exit 2015-04-10 17:39:06 +00:00
sort sort: fixed small typo in comments 2015-02-08 23:38:50 +00:00
strconv strconv: use 64bit uint for decimal conversion if available 2015-04-10 17:42:20 +00:00
strings bytes, strings: add Reader.Size methods 2015-04-06 08:53:47 +00:00
sync sync/atomic: add support for GOARCH=arm64 2015-03-16 18:46:18 +00:00
syscall syscall: correct code for cover cmd 2015-04-10 16:59:06 +00:00
testing testing/quick: fix comment 2015-03-27 13:00:53 +00:00
text text/template: provide a mechanism for options 2015-04-03 23:40:59 +00:00
time time: unify formatting of decimals for timestamps 2015-04-08 16:17:22 +00:00
unicode all: use "reports whether" in place of "returns true if(f)" 2015-03-18 15:14:06 +00:00
unsafe
all.bash
all.bat
all.rc
androidtest.bash androidtest.bash: copy pkg for gcimporter tests 2015-04-08 14:39:07 +00:00
bootstrap.bash build: add bootstrap.bash for bootstrapping new systems 2015-03-02 17:51:56 +00:00
clean.bash
clean.bat
clean.rc
iostest.bash iostest.bash: warn if GOARCH is not correct 2015-04-03 18:51:42 +00:00
make.bash [dev.cc] cmd/go: fix expansion of 'std', add 'cmd' 2015-02-23 15:13:17 +00:00
make.bat build: update Windows make.bat to use CC_FOR_TARGET. 2015-03-02 02:20:46 +00:00
Make.dist
make.rc all: delete C libraries and cmd/dist code that builds them 2015-03-01 00:40:23 +00:00
nacltest.bash nacltest.bash: reduce test time by using bootstrapping Go to build fstest_nacl.go 2015-03-24 23:58:14 +00:00
race.bash [dev.cc] cmd/go: fix expansion of 'std', add 'cmd' 2015-02-23 15:13:17 +00:00
race.bat [dev.cc] cmd/go: fix expansion of 'std', add 'cmd' 2015-02-23 15:13:17 +00:00
run.bash build: convert run.bash, run.bat, and run.rc into a Go program 2015-03-03 23:22:11 +00:00
run.bat build: convert run.bash, run.bat, and run.rc into a Go program 2015-03-03 23:22:11 +00:00
run.rc build: convert run.bash, run.bat, and run.rc into a Go program 2015-03-03 23:22:11 +00:00