Why is this D code slower than C++?
Bradley Smith
digitalmars-com at baysmith.com
Thu Jan 18 16:53:18 PST 2007
Yes, I see that behavior too. Using doubles, here is what I get.
dmc 6 sec
dmd 19 sec
gdc 17 sec
msvc 4 sec
It is also interesting that the msvc gets better where the dmc gets
worse. I wouldn't stake to much on it though, since these are
approximate timings.
Thanks,
Bradley
Daniel Giddings wrote:
> Try this version. In MSVC C++, float -> double, funcf -> func for the
> floating funcs (sqrtf, expf). It improves the time from 8.6 to 5.7
> seconds on my computer. The same process makes the D version slower.
>
> Bradley Smith wrote:
>>
>> Bradley Smith wrote:
>>> As Bill Baxter pointed out, I missed an optimization on version 2.
>>> The pass by reference optimization using the inout on the Intersect's
>>> Ray argument. I had applied inout only to the Raytrace's Ray argument.
>>>
>>> The further optimization brings the following approx. timings:
>>>
>>> time factor
>>> dmc 5 sec 1.0
>>> dmd 9 sec 1.8
>>> gdc 13 sec 2.6
>> gdc 10 sec 2.0 <-- correction
>>> msvc 5 sec 1.0
>>> g++ doesn't compile
>>>
>>
>> Here is a correction to the gdc results. The wrong optimization flag
>> was used. The build_d_gdc.bat should have "-O3" rather than "-O".
>
More information about the Digitalmars-d-learn
mailing list