Years ago on many projects we would gladly accept a longer compile time for a faster execution at runtime. However with the acceptance of continuous integration gaining momentum, it’s not “always” a clearly acceptable trade-off. With more frequent code submissions, it’s become desirable to compile and test each submission as independently as possible. This (ideally) allows any compilation errors or test failures to be rapidly traceable to the rogue coder’s submission. Now the trade-off hasn’t just changed. It’s mostly gone. We need to both have fast compile times, and blazing execution. Luckily, this is where judicious software design can help.
The idea of keyword inline is to speed up code execution by inserting the definition of the inlined function directly a the site of the function call. You can read about in the standard [dcl.inline / 10.1.6]. For a function definition of a single line, we can see how avoiding a function call can be beneficial. That single line of code gets inserted directly into the calling code. But, there a plenty of reasons why you mostly don’t want to use inline, unless that function to be inlined is very simple and short as described above.
Continue reading “Runtime vs Compilation speed – The new deal“