QuoteOriginally posted by: CuchulainnWelcome to Wilmott.A while ago we did tests and found CRTP was 8-12 faster hereI have a few questions:1. When you say inlining with CRTP, do you mean in Base, Derived or both? In general, inline in Derived will not always be achievable?2. Instead of dynamic or static inheritance, what about plan to create ONE class with embedded function wrapper?class C{std::function<int (int)> tickDelegate;}Nice layout :-)Sorry for extremely late reply.I have been re-looking at it. Seperated CRTP and virtual methods source files , to be able to look at assembly outputs seperately.First thing is , I decreased number of iterations and I got a different result. With O3 and inlining , CRTP was only 6.5ish faster than virtual methods.As also looked at asm output, the indirection in virtual method is obvious , but the more eye-catching part was seeing SIMD instructions in CRTP. ( paddd )Here is updated blog page :
https://nativecoding.wordpress.com/2015 ... mark-2/And here is the source codes with assembly outputs :
https://github.com/akhin/benchmarks/tre ... pRegarding inling, to my understanding at least in the debugger , base class is inlined into derived method , definitely no indirectionAs for the second one, my purpose was just seeing CRTP against virtual methods since it still allows me to use a base pointer to refer to different types , without changing existing code too much.Honestly I am not aware of that method. ( One big class )