commons-issues mailing list archives

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

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

Arne Plöse commented on MATH-579:
---------------------------------

This happens only on the first! run.
So take a separate project and run this test case:


    @Test
    public void testPowDuration() {
        int n = 10;
        long t1 = System.currentTimeMillis();
        for (int i = 0; i < n; i++) {
            double x1 = FastMath.pow(10, 0.1 / 20);
        }
        long t2 = System.currentTimeMillis();
        for (int i = 0; i < n; i++) {
            double x1 = Math.pow(10, 0.1 / 20);
        }
        long t3 = System.currentTimeMillis();
        double d1 = t2 - t1;
        double d2 = t3 - t2;
          if (d2 == 0) {
            d2 = 1;
        }
        if (d1 / d2 > 2.0)
            throw new RuntimeException("pow(10, 0.1 / 20) ratio" + (d1 / d2));
    }
Looks like some initialization takes quite long ...

> 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