• Rémy Oudompheng's avatar
    strconv: faster FormatFloat for fixed number of digits. · c1c02796
    Rémy Oudompheng authored
    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
    c1c02796
extfloat.go 19.8 KB