On Thursday, 5 April 2012 at 23:23:54 UTC, Kapps wrote:
On Thursday, 5 April 2012 at 17:22:38 UTC, Minas wrote:
First, you should compile with -O -release -inline and, in this
case, -noboundscheck.
return false;
Results in a 26 times performance increase for me, based off of
using a StopWatch at start of main and stopping it at end of
main. It's possible that the C compiler can recognize that this
is a constant expression (sqrt might be an intrinsic). D should
be able to do this even better; sqrt is strongly pure and takes
in arguments that do not change, thus it should be able to
automatically make the change I did above. It (at least DMD)
does not seem to however.
I did not try the C version, and the D version was compiled
with DMD on Windows.
Thank you, that made it run 300ms faster than the C version!
Could this be a bug in dmd that I should report?