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

Gilles commented on MATH-841:
-----------------------------

I confirm that our current implementation is about 40% to 95% slower than yours:

{noformat}
gcd (calls per timed block: 10000, timed blocks: 100, time unit: ms)
           name      time/call      std error total time      ratio      
difference
        Math841 1.89538209e-04 5.65309713e-05 1.8954e+02 1.0000e+00  
0.00000000e+00
ArithmeticUtils 2.71731169e-04 1.04170594e-04 2.7173e+02 1.4336e+00  
8.21929600e+01

gcd (calls per timed block: 100000, timed blocks: 100, time unit: ms)
           name      time/call      std error total time      ratio      
difference
        Math841 1.63301724e-04 1.74326152e-05 1.6330e+03 1.0000e+00  
0.00000000e+00
ArithmeticUtils 3.18518260e-04 1.26757437e-05 3.1852e+03 1.9505e+00  
1.55216536e+03
{noformat}

Would you please send a message to the "dev" ML, drawing attention to this 
report?
Also, if we are to change the implementation, the code should conform to the CM 
formatting style...
Thanks.

                
> gcd speed up
> ------------
>
>                 Key: MATH-841
>                 URL: https://issues.apache.org/jira/browse/MATH-841
>             Project: Commons Math
>          Issue Type: Improvement
>    Affects Versions: 3.0
>         Environment: ubuntu 32bits/intel-i5/java6
>            Reporter: Sebastien Riou
>            Priority: Trivial
>              Labels: patch, performance
>             Fix For: 3.1
>
>         Attachments: ArithmeticUtils.java, patchGcdInt.txt
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> The gcd(int,int) method of ArithmeticUtils seems 2 times slower than the 
> naive approach using modulo operator. The following test code runs in 11s 
> with current version and in 6s with the patch.
> public void testApache(){
>         Random rng=new Random(0);
>         long checksum=0;
>         long start=System.nanoTime();
>         checksum+=gcd(0,Integer.MAX_VALUE);
>         checksum+=gcd(Integer.MAX_VALUE,0);
>         checksum+=gcd(Integer.MAX_VALUE,rng.nextInt());
>         for(int i=0;i<10000;i++) 
> checksum+=gcd(rng.nextInt(),Integer.MAX_VALUE);
>         checksum+=gcd(Integer.MAX_VALUE,Integer.MAX_VALUE);
>         checksum+=gcd(Integer.MIN_VALUE,1<<30);
>         checksum+=gcd(1<<30,1<<30);
>         checksum+=gcd(3 * (1<<20),9 * (1<<15));
>         for(int i=0;i<30000000;i++) 
> checksum+=gcd(rng.nextInt(),rng.nextInt());
>         long end=System.nanoTime();
>         long tns=end-start;
>         long tms=(tns+500000)/1000000;
>         long ts=(tms+500)/1000;
>         System.out.println("exec time="+ts+"s, ("+tms+"ms), 
> checksum="+checksum);
>         assertEquals(9023314441L,checksum);
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to