Rquest for timings

Andrea Fontana advmail at katamail.com
Fri Nov 25 05:53:19 PST 2011


Really? Dmd version and system? (here: dmd from git, ubuntu 11.10 64bit)

./app 50000000

Your version:
real	0m14.674s

My version:
real	0m13.644s

Your version:
imd dSquared = dx ^^ 2 + dy ^^ 2 + dz ^^ 2;   
imd mag = dt / (dSquared * sqrt(dSquared));

My version:
imd dSquared = sqrt(dx ^^ 2 + dy ^^ 2 + dz ^^ 2);
imd mag = dt / (dSquared * dSquared^^2);  // That is: dt /
(dSquared^^3);
 
Probably vars evaluation works better on my example? 

Btw:

imd dSquared = sqrt(dx*dx + dy*dy + dz*dz);
imd mag = dt / (dSquared*dSquared*dSquared);

real	0m13.574s


Il giorno ven, 25/11/2011 alle 08.14 -0500, bearophile ha scritto:

> Andrea Fontana:
> 
> > Hmm reading code i verified that i can gain a 10% writing:
> > 
> >                     imd dSquared = sqrt(dx ^^ 2 + dy ^^ 2 + dz ^^ 2);
> >                     imd mag = dt / (dSquared * dSquared^^2);
> > 
> > Around line 115. Give it a try... 
> 
> My version performs a sqrt and one multiplication, while your version performs one sqrt and two multiplications. On my PC my version is faster.
> 
> Bye,
> bearophile
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20111125/32f6973d/attachment.html>


More information about the Digitalmars-d-learn mailing list