Why is this D code slower than C++?

Bradley Smith digitalmars-com at baysmith.com
Wed Jan 17 11:18:10 PST 2007


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)
   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
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: raytracer3_cpp_d_2.zip
Type: application/octet-stream
Size: 20633 bytes
Desc: not available
Url : http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20070117/2f03cb26/attachment-0001.obj 


More information about the Digitalmars-d-learn mailing list