D slower ~1s from C ?!

Minas minas_mina1990 at hotmail.co.uk
Fri Apr 6 00:34:10 PDT 2012


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?


More information about the Digitalmars-d-learn mailing list