<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/4.1.92">
</HEAD>
<BODY>
Really? Dmd version and system? (here: dmd from git, ubuntu 11.10 64bit)<BR>
<BR>
./app 50000000<BR>
<BR>
Your version:<BR>
real 0m14.674s<BR>
<BR>
My version:<BR>
real 0m13.644s<BR>
<BR>
Your version:<BR>
imd dSquared = dx ^^ 2 + dy ^^ 2 + dz ^^ 2; <BR>
imd mag = dt / (dSquared * sqrt(dSquared));<BR>
<BR>
My version:<BR>
imd dSquared = sqrt(dx ^^ 2 + dy ^^ 2 + dz ^^ 2);<BR>
imd mag = dt / (dSquared * dSquared^^2); // That is: dt / (dSquared^^3);<BR>
<BR>
Probably vars evaluation works better on my example? <BR>
<BR>
Btw:<BR>
<BR>
imd dSquared = sqrt(dx*dx + dy*dy + dz*dz);<BR>
imd mag = dt / (dSquared*dSquared*dSquared);<BR>
<BR>
real 0m13.574s<BR>
<BR>
<BR>
Il giorno ven, 25/11/2011 alle 08.14 -0500, bearophile ha scritto:
<BLOCKQUOTE TYPE=CITE>
<PRE>
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
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>