O'Reilly logo

Efficient C++ Performance Programming Techniques by David Mayhew, Dov Bulka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performance Gains from Inlining

Consider the effect of inlining a simple access method (a method that provides access to one of an object's attributes):

int x::get_y()
{
    return y;
}

The method itself probably requires only three or four cycles. If invoked, even this trivial method can generate as much as 20 cycles of overhead. If inlined the method will consume only the one or two cycles (two less than the original instruction count because there are no call and return instructions any more). Thus, inlining can provide as much as a 10x speed up. It should also be remembered that most of those 20 cycles of saved overhead had instructions associated with them. This means that in addition to saving the 20 cycles of overhead, we also decreased ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required