Function Call Overhead

The measurements on this page are based on tests from the C++ Performance TR1. This page specificallly contains tests similar to those from section 5.3 (Classes and Interfaces) measuring the overhead of different approaches to call functions.

The tests are not identical to those used by the performance TR, primarily to address some slightly questionable pratices (e.g., not initializing variables) and to fit them into the commonly used framework. Also, compilers have become a lot smarter and actually see through a number of the uses and entirely optimize away what is intended to be measured. Thus, the tests use xor instead of addition because compilers see through the use addition and optimize the entire loop out while they don't optimize this use of xor.

What's Being Tested

All the tests do the moral equivalent of this loop
unsigned int x(0u);
unsigned int n(10000000u);
for (unsigned int i(0u); i != n; ++i) {
    x ^= i;
}
with the core of the loop (x ^= i;) replaced by a function call using an object suitable for the function call to be worked on.

Report Conventions

Object Names

The naming convention for the names of objects is as follows:
xan object of base type X
xpa pointer to an object of type X
yan object of derived type Y using X as a base
ypa pointer of derived type Y using X as a base
oan object of type S

Function Names

The components of the function names being called is as follows:
nmnon-member
sstatic
nvnon-virtual
vvirtual
odefined in other source file
idefined inline
cdefined in the class body or upon its first declaration
pa pointer to function or pointer to member function

Results