Why is this D code slower than C++?
Bill Baxter
dnewsgroup at billbaxter.com
Wed Jan 17 17:50:23 PST 2007
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.
--bb
More information about the Digitalmars-d-learn
mailing list