Finding large difference b/w execution time of c++ and D codes for same problem

Rob T alanb at ucora.com
Tue Feb 12 22:01:27 PST 2013


Well technically it was that much faster because it did optimize 
away the useless calcOn Tuesday, 12 February 2013 at 23:31:17 
UTC, FG wrote:
> On 2013-02-13 00:06, Sparsh Mittal wrote:
>>
>>> I had a look, but first had to make juliaValue global, 
>>> because g++ had
>>> optimized all the calculations away.
>>
>> Brilliant! Yes, that is why the time was coming out to be 
>> zero, regardless of
>> what value of DIM I put. Thank you very very much.
>
> LOL. For a while you thought that C++ could be that much faster 
> than D?  :D

Well technically it's not that C++ is faster than D or 
visa-versa, it's that the two compilers did different 
optimizations, and in this case one of the optimizations that g++ 
did (removing redundancies) had a large effect on the outcome. 
It's entirely possible that DMD can still beat g++ under 
different circumstances.

--rt


More information about the Digitalmars-d-learn mailing list