Why is this D code slower than C++?

Bill Baxter dnewsgroup at billbaxter.com
Thu Jan 18 10:02:33 PST 2007


Bradley Smith wrote:
> 
> 
> Dave wrote:
>> %u wrote:
>>> Bill Baxter Wrote:
>>>> So the C++ code is ok.  But it's not clear why Material became a
>>>> class in the D version rather than a struct.
>>> Thx. I did not notice, that "Material" is a struct in the cpp-version.
>>>
>>> This shows however, that programmers still are not following 
>>> engeering principles: no technical documentation of the port is given 
>>> and no one complains.
>>>
>>> Instead several people are eager searching flaws in the reference 
>>> implementation of D for which there is also no technical 
>>> documentation :-(
>>
>> Let's assume that the OP was earnestly trying to make the C++ and D 
>> code comparable... If so, then this exercise did point out some areas 
>> where D needs attention. In the final analysis, it's "good faith" 
>> ports like these that are going to satisfy whether or not D "is as 
>> fast or faster" than C++, and in many cases, whether or not people 
>> will make the switch. If it requires a lot of code modifications over 
>> and above a simple port to make D comparable in performance, people 
>> will shy away from D.
> 
> Thanks for defending me, Dave. You are correct in assuming that I am 
> trying to make the C++ and D code comparable. I'm not trying to sabotage 
> the D effort. In fact, I would very much like to see the D code perform 
> significantly better than C++. I'm just trying to learn how to write 
> high-performance D code.
> 
> Thanks,
>   Bradley


I think this was a great little benchmark you posted.  I hope Walter 
takes some interest in this too, because he's consistently responded to 
performance questions with "I bet it'll be the same if you compile with 
DMC and DMD".  But now at last we have a real-world kind of benchmark 
with which to test that assertion.  The answer appears to be negative at 
the moment, but just as with bugs, you can't fix it if you can't 
reproduce the problem.  And you've given us a very nice repro case.

--bb


More information about the Digitalmars-d-learn mailing list