struct Tester { void normalFunction() {} virtual void virtualFunction() = 0;};struct DerivedTester : Tester { void virtualFunction() {}};void benchmark(Tester &the_tester) { // do your test here, if the compiler isn't very clever it // will not generate optimized versions of this function}
it will only tell you the relative performance between a function call and a virtual function call. Even if it is 100% slower, the entire thing comes down to such a low number of clock cycles compared to any function body you would normally write that it doesn't matter at all.
For most C++ compilers on x86, a virtual call causes an overhead of exactly two instructions, namely an 'inc'/'dec' plus a 'jmp'. As has been said, most CPUs are optimized for the typical code flow in a virtual call because it is shared by most current software. Granted, you shouldn't use virtual functions nested three levels deep if you're blitting pixels, but I've never ever seen a virtual function to be the root of evil, or incurrent any noticable impact at all, when making profiler runs on my projects.
-Markus-