Faster Math ?
Andrew Haley
aph at redhat.com
Thu Nov 9 16:08:00 UTC 2017
On 09/11/17 15:02, Laurent Bourgès wrote:
> --- testing cbrt(double) = pow(double, 1/3) ---
> Loop on Math.pow(double, 1/3), args in [-10.0,10.0], took 0.739 s
> Loop on FastMath.cbrt(double), args in [-10.0,10.0], took 0.166 s
> Loop on Math.pow(double, 1/3), args in [-0.7,0.7], took 0.746 s
> Loop on FastMath.cbrt(double), args in [-0.7,0.7], took 0.166 s
> Loop on Math.pow(double, 1/3), args in [-0.1,0.1], took 0.742 s
> Loop on FastMath.cbrt(double), args in [-0.1,0.1], took 0.165 s
> Loop on Math.pow(double, 1/3), args in all magnitudes, took 0.753 s
> Loop on FastMath.cbrt(double), args in all magnitudes, took 0.244
>
> Conclusion:
> - acos / asin / atan functions are quite slow: it confirms these are not
> optimized by hotspot intrinsics.
>
> - cbrt() is slower than sqrt() : 1.1s vs 0.1 => 10x slower
> - cbrt() is slower than pow(1/3) : 1.1s vs 0.7s => 50% slower
No. cbrt() is faster than pow(1/3) : 0.24 vs 0.75
--
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the core-libs-dev
mailing list