diff options
| author | Rémy Oudompheng <oudomphe@phare.normalesup.org> | 2011-12-19 15:03:53 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2011-12-19 15:03:53 -0500 |
| commit | 3a2dec0246fe66af7871edd4b84840371988aeb2 (patch) | |
| tree | 3b0ebb97932159b03a904c4d747022f21c3123eb /src/pkg | |
| parent | 178be83e0eb465156be32c69e59aba0f815fb746 (diff) | |
| download | go-3a2dec0246fe66af7871edd4b84840371988aeb2.tar.xz | |
strconv: reduce buffer size for multi-precision decimals.
The longest numbers we have to represent are the smallest denormals.
Their decimal mantissa is not longer than 5^1100. Taking into
account some extra size for in-place operations, 800 digits are
enough. This saves time used for zero intiialization of extra
bytes.
old ns/op new ns/op delta
strconv_test.BenchmarkAtof64Decimal 521 334 -35.9%
strconv_test.BenchmarkAtof64Float 572 391 -31.6%
strconv_test.BenchmarkAtof64FloatExp 10242 10036 -2.0%
strconv_test.BenchmarkAtof64Big 4229 4029 -4.7%
strconv_test.BenchmarkFormatFloatDecimal 1396 934 -33.1%
strconv_test.BenchmarkFormatFloat 4295 3341 -22.2%
strconv_test.BenchmarkFormatFloatExp 12035 11181 -7.1%
strconv_test.BenchmarkFormatFloatBig 4213 3229 -23.4%
strconv_test.BenchmarkAppendFloatDecimal 1031 600 -41.8%
strconv_test.BenchmarkAppendFloat 3971 3044 -23.3%
strconv_test.BenchmarkAppendFloatExp 11699 11003 -5.9%
strconv_test.BenchmarkAppendFloatBig 3836 2915 -24.0%
R=golang-dev, bradfitz, rsc
CC=golang-dev, remy
https://golang.org/cl/5491064
Diffstat (limited to 'src/pkg')
| -rw-r--r-- | src/pkg/strconv/decimal.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/pkg/strconv/decimal.go b/src/pkg/strconv/decimal.go index 541553097b..cc5591a8d8 100644 --- a/src/pkg/strconv/decimal.go +++ b/src/pkg/strconv/decimal.go @@ -14,9 +14,9 @@ package strconv type decimal struct { // TODO(rsc): Can make d[] a bit smaller and add // truncated bool; - d [2000]byte // digits - nd int // number of digits used - dp int // decimal point + d [800]byte // digits + nd int // number of digits used + dp int // decimal point neg bool } |
