Why is this D code slower than C++?

Dave Dave_member at pathlink.com
Wed Jan 17 17:28:23 PST 2007


Bradley Smith wrote:
> Thanks for all the suggestions. It helps, but not enough to make the D 
> code faster than the C++. It is now 2.6 times slower. The render times 
> are now approx. 13 sec for raytracer_d and approx. 5 sec for raytracer_cpp.
> 
> Here are the changes I've made. Attached is the new code.
> 
>   Call RegisterClass outside of assert. (Broken if -release used)
>   Apply -release option. (Increases speed in an unknown way)
>   Converted templates to regular functions. (Templates not being inlined)

Are you sure? I know templates can be/are inlined and I guess I haven't noticed anywhere they aren't 
were I'd expect a regularly defined function to be inlined.

>   Manually inlined DOT function. (Function not being inlined)
> 
> 
> Any other suggestions?
> 
> Thanks,
>   Bradley
> 
> Bradley Smith wrote:
>> Jacco Bikker wrote several raytracing articles on DevMaster.net. I 
>> took his third article and ported it to D. I was surprised to find 
>> that the D code is approx. 4 times slower than C++.
>>
>> The raytracer_d renders in approx. 21 sec and the raytracer_cpp 
>> renders in approx. 5 sec. I am using the DMD and DMC compilers on 
>> Windows.
>>
>> How can the D code be made to run faster?
>>
>> Thanks,
>>   Bradley
>>


More information about the Digitalmars-d-learn mailing list