Why is this D code slower than C++?

Dave Dave_member at pathlink.com
Fri Jan 19 08:01:53 PST 2007


Bill Baxter wrote:
> Dave wrote:
>> 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.
> 
> I changed a bunch parameters to inout after discovering that it made a 
> difference for the Intersect method.  It could be that I had the 
> template parameters as inout at the time when getting rid of the 
> templates seemed to make a difference.
> 
> That's evil that inout disables inlining.
> Seems like inout params would be easier to inline than regular 
> parameters, but I guess not.

I agree and have been wondering about that for some time - my guess is that it caused some type of 
bug early on and Walter didn't have the time to loop back and fix.

> 
> --bb


More information about the Digitalmars-d-learn mailing list