• Martin Möhrmann's avatar
    strconv: fix performance regression in integer formatting on 32bit platforms · b71ed4ed
    Martin Möhrmann authored
    Some of the changes in CL golang.org/cl/38071/ assumed that / and %
    could always be combined to use only one DIV instruction. However,
    this is not the case for 64bit operands on a 32bit platform which use
    seperate runtime functions to calculate division and modulo.
    
    This CL restores the original optimizations that help on 32bit platforms
    with negligible impact on 64bit platforms.
    
    386:
    name          old time/op  new time/op  delta
    FormatInt-2   6.06µs ± 0%  6.02µs ± 0%  -0.70%  (p=0.000 n=20+20)
    AppendInt-2   4.98µs ± 0%  4.98µs ± 0%    ~     (p=0.747 n=18+18)
    FormatUint-2  1.93µs ± 0%  1.85µs ± 0%  -4.19%  (p=0.000 n=20+20)
    AppendUint-2  1.71µs ± 0%  1.64µs ± 0%  -3.68%  (p=0.000 n=20+20)
    
    amd64:
    name          old time/op  new time/op  delta
    FormatInt-2   2.41µs ± 0%  2.41µs ± 0%  -0.09%  (p=0.010 n=18+18)
    AppendInt-2   1.77µs ± 0%  1.77µs ± 0%  +0.08%  (p=0.000 n=18+18)
    FormatUint-2   653ns ± 1%   653ns ± 0%    ~     (p=0.178 n=20+20)
    AppendUint-2   514ns ± 0%   513ns ± 0%  -0.13%  (p=0.000 n=20+17)
    
    Change-Id: I574a18e54fb41b25fbe51ce696e7a8765abc79a6
    Reviewed-on: https://go-review.googlesource.com/38051
    Run-TryBot: Martin Möhrmann <moehrmann@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
    b71ed4ed
itoa.go 3.7 KB