3 ms·
I had this benchmark that used to show a 10% difference between non-inlined and virtual: https://gist.github.com/haberman/5621682 https://gist.github.com/haberm
by haberman 12y ago
I had this benchmark that used to show a 10% difference between non-inlined and virtual: https://gist.github.com/haberman/5621682 https://gist.github.com/haberman/5621682
But since I wrote that, compilers have gotten too smart. When I tried it just now, the compiler devirtualized the function call (which I verified by reading the assembly language output).
I should mention though, the the inability to inline virtual functions is part of what makes them less efficient in some cases. Isolating the inlining factor removes one of the benefits that makes non-virtual functions perform better.