Why is this D code slower than C++?
Bradley Smith
digitalmars-com at baysmith.com
Thu Jan 18 12:56:19 PST 2007
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
msvc 5 sec 1.0
g++ doesn't compile
Version 3 is attached and has the following changes:
Fixed compiling with gdc
Use inout for Intersect's Ray argument
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_3.zip
Type: application/octet-stream
Size: 21214 bytes
Desc: not available
Url : http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20070118/a861c6ea/attachment-0001.obj
More information about the Digitalmars-d-learn
mailing list