commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luc Maisonobe (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-579) FastMath.pow much slower than Math.pow
Date Tue, 17 May 2011 19:35:47 GMT

    [ https://issues.apache.org/jira/browse/MATH-579?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13034996#comment-13034996
] 

Luc Maisonobe commented on MATH-579:
------------------------------------

This is normal and is probably the same for all FastMath methods (I just checked for sin,
abs and sqrt, knowing that FastMath.sqrt simply calls Math.sqrt). The initialization occurs
at class loading as many tables are computed, so this overhead occurs only one per program
run and does not change with the number of calls.

The number of calls is also important as the native code optimizing compilers kicks of only
after the same part of code has been used many times. FastMath relies heavily on this and
attempts to be fast for large scale computation. The side effect you see is that it is much
slower for very short programs like the benchmark above.

Also note that 10 runs is far too low with regard to both the resolution of currentTimeMillis
(one can use System.nanoTime() instead) and for results significance.

So I would like to close this as WONTFIX. Perhaps we should add in the javadoc that FastMath
targets large scale computation.

> FastMath.pow much slower than Math.pow
> --------------------------------------
>
>                 Key: MATH-579
>                 URL: https://issues.apache.org/jira/browse/MATH-579
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: java version "1.6.0_22"
> OpenJDK Runtime Environment (IcedTea6 1.10.1) (6b22-1.10.1-0ubuntu1)
> OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
> java version "1.6.0_24"
> Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
> Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
>            Reporter: Arne Plöse
>
> calculating FastMath.pow(10, 0.1 / 20) is approximately 65 times slower as the Math.pow()
function.
> Ether this is a bug or a javadoc comment is missing.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message