]> Cypherpunks repositories - gostls13.git/commit
strconv: faster FormatFloat for fixed number of digits.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Sat, 1 Sep 2012 14:31:46 +0000 (16:31 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Sat, 1 Sep 2012 14:31:46 +0000 (16:31 +0200)
commitc1c027964e17d9c3f8acb4a9136698ae696a14e8
treed6d8e9b90e74c656d086f09d748334a17f32d533
parent5a78e5ea4c3cd4d6029882a9e45c0c5506c2babb
strconv: faster FormatFloat for fixed number of digits.

The performance improvement applies to the case where
prec >= 0 and fmt is 'e' or 'g'.

Additional minor optimisations are included. A small
performance impact happens in some cases due to code
refactoring.

benchmark                              old ns/op    new ns/op    delta
BenchmarkAppendFloat64Fixed1                 623          235  -62.28%
BenchmarkAppendFloat64Fixed2                1050          272  -74.10%
BenchmarkAppendFloat64Fixed3                3723          243  -93.47%
BenchmarkAppendFloat64Fixed4               10285          274  -97.34%

BenchmarkAppendFloatDecimal                  190          206   +8.42%
BenchmarkAppendFloat                         387          377   -2.58%
BenchmarkAppendFloatExp                      397          339  -14.61%
BenchmarkAppendFloatNegExp                   377          336  -10.88%
BenchmarkAppendFloatBig                      546          482  -11.72%

BenchmarkAppendFloat32Integer                188          204   +8.51%
BenchmarkAppendFloat32ExactFraction          329          298   -9.42%
BenchmarkAppendFloat32Point                  400          372   -7.00%
BenchmarkAppendFloat32Exp                    369          306  -17.07%
BenchmarkAppendFloat32NegExp                 372          305  -18.01%

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6462049
src/pkg/strconv/extfloat.go
src/pkg/strconv/ftoa.go
src/pkg/strconv/ftoa_test.go