Re: template classes faster than derived classes?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nava Whiteford wrote:
Thanks for your extremely quick response and suggestions.

I've reworked the code so it no longer does as much IO. The difference
is striking!

http://linuxjunk.blogspot.com/2009/11/are-templates-faster-than-subclasses.html

5.9s for derived class, 0.008s for the templated version.

I'm guessing that it's automatically inlining the code in the template
version? And the virtual method can not be inlined (is this ever
possible?).


I didn't see the first version. In the current version, the templated code is simple enough that the optimizer can figure out the whole thing and skip everything. The virtual code is not simple enough, so the code actually executes.

So you still aren't measuring what you set out to measure.

I don't know whether there are conditions under which the optimizer can take advantage of being able to deduce the run time type in order to optimize away the vtable lookup and then further optimize to inlining the function rather than calling it.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux