Slow performance compared to C++, ideas?
Manu
turkeyman at gmail.com
Fri May 31 04:50:50 PDT 2013
On 31 May 2013 21:05, Timon Gehr <timon.gehr at gmx.ch> wrote:
> On 05/31/2013 12:58 PM, Joseph Rushton Wakeling wrote:
>
>> On 05/31/2013 08:34 AM, Manu wrote:
>>
>>> What's taking the most time?
>>> The lighting loop is so template-tastic, I can't get a feel for how fast
>>> that
>>> loop would be.
>>>
>>
>> Hah, I found this out the hard way recently -- have been doing some
>> experimental
>> reworking of code where some key inner functions were templatized, and it
>> had a
>> nasty effect on performance. I'm guessing it made it impossible for the
>> compilers to inline these functions :-(
>>
>>
> That wouldn't make any sense though, since after template expansion there
> is no difference between the generated version and a particular handwritten
> version.
>
Assuming that you would hand-write exactly the same code as the template
expansion...
Typically template expansion leads to countless temporary redundancies,
which you expect the compiler to try and optimise away, but it's not always
able to do so, especially if there is an if() nearby, or worse, a pointer
dereference.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130531/1bea3794/attachment.html>
More information about the Digitalmars-d
mailing list