Why is this D code slower than C++?

Daniel Giddings dgiddings at bigworldtech.com
Thu Jan 18 14:36:46 PST 2007


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".

-------------- next part --------------
A non-text attachment was scrubbed...
Name: raytracer3.zip
Type: application/x-zip-compressed
Size: 20732 bytes
Desc: not available
Url : http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20070119/585d606e/attachment-0001.bin 


More information about the Digitalmars-d-learn mailing list