• Brian Kessler's avatar
    math/big: optimize multiplication by 2 and 1/2 in float Sqrt · 3fd62ce9
    Brian Kessler authored
    The Sqrt code previously used explicit constants for 2 and 1/2.  This change
    replaces multiplication by these constants with increment and decrement of
    the floating point exponent directly.  This improves performance by ~7-10%
    for small inputs and minimal improvement for large inputs.
    
    name                 old time/op    new time/op    delta
    FloatSqrt/64-4         1.39µs ± 0%    1.29µs ± 3%   -7.01%  (p=0.016 n=4+5)
    FloatSqrt/128-4        2.84µs ± 0%    2.60µs ± 1%   -8.33%  (p=0.008 n=5+5)
    FloatSqrt/256-4        3.24µs ± 1%    2.91µs ± 2%  -10.00%  (p=0.008 n=5+5)
    FloatSqrt/1000-4       7.42µs ± 1%    6.74µs ± 0%   -9.16%  (p=0.008 n=5+5)
    FloatSqrt/10000-4      65.9µs ± 1%    65.3µs ± 4%     ~     (p=0.310 n=5+5)
    FloatSqrt/100000-4     1.57ms ± 8%    1.52ms ± 1%     ~     (p=0.111 n=5+4)
    FloatSqrt/1000000-4     127ms ± 1%     126ms ± 1%     ~     (p=0.690 n=5+5)
    
    Change-Id: Id81ac842a9d64981e001c4ca3ff129eebd227593
    Reviewed-on: https://go-review.googlesource.com/130835Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
    3fd62ce9
Name
Last commit
Last update
..
accuracy_string.go Loading commit data...
arith.go Loading commit data...
arith_386.s Loading commit data...
arith_amd64.go Loading commit data...
arith_amd64.s Loading commit data...
arith_amd64p32.s Loading commit data...
arith_arm.s Loading commit data...
arith_arm64.s Loading commit data...
arith_decl.go Loading commit data...
arith_decl_pure.go Loading commit data...
arith_decl_s390x.go Loading commit data...
arith_mips64x.s Loading commit data...
arith_mipsx.s Loading commit data...
arith_ppc64x.s Loading commit data...
arith_s390x.s Loading commit data...
arith_s390x_test.go Loading commit data...
arith_test.go Loading commit data...
arith_wasm.s Loading commit data...
bits_test.go Loading commit data...
calibrate_test.go Loading commit data...
decimal.go Loading commit data...
decimal_test.go Loading commit data...
doc.go Loading commit data...
example_rat_test.go Loading commit data...
example_test.go Loading commit data...
float.go Loading commit data...
float_test.go Loading commit data...
floatconv.go Loading commit data...
floatconv_test.go Loading commit data...
floatexample_test.go Loading commit data...
floatmarsh.go Loading commit data...
floatmarsh_test.go Loading commit data...
ftoa.go Loading commit data...
gcd_test.go Loading commit data...
hilbert_test.go Loading commit data...
int.go Loading commit data...
int_test.go Loading commit data...
intconv.go Loading commit data...
intconv_test.go Loading commit data...
intmarsh.go Loading commit data...
intmarsh_test.go Loading commit data...
nat.go Loading commit data...
nat_test.go Loading commit data...
natconv.go Loading commit data...
natconv_test.go Loading commit data...
prime.go Loading commit data...
prime_test.go Loading commit data...
rat.go Loading commit data...
rat_test.go Loading commit data...
ratconv.go Loading commit data...
ratconv_test.go Loading commit data...
ratmarsh.go Loading commit data...
ratmarsh_test.go Loading commit data...
roundingmode_string.go Loading commit data...
sqrt.go Loading commit data...
sqrt_test.go Loading commit data...