3 ms·
If you just want the number: dynamic is 6x slower.
by ambrop7 12y ago
If you just want the number: dynamic is 6x slower.
- vmarsy 12y agoThat is with gcc -O2 (version 4.8) on an i7-4771 CPU With -O3 the speedup is even more: 7.2x on a Xeon E5-2690 (Sandy Bridge) with gcc 4.6.3 (same code generated) it was "only" 3x
- rurban 12y ago... with older compilers, without -fdevirtualize.
- npalli 12y agoNot a good summary. 1. If the static method is trivial enough, the compiler can inline it removing the need for a function call. In that case, a virtual function call for a single increment op is 6 times slower. 2. If you disable inlining for the static method, curiously it is 1.5 times slower than the virtual function call. 3. Newer compilers have devirtualize that the OP could not test but should be able to give much better than the 6x degradation.