tgoe wrote:I hate to be that guy again but this does really bother me. If you're doing 99999 iterations of useful work, function call overhead is the least of your worries. By your posts, thetan, the cost of those function calls in terms of time is approx: 2.00002 * 10 ** -5s.
Some one hasn't done much work with big data and map reduce jobs that take entire days to finish .....
enough said.
tgoe wrote:So if you have a chunk of code that takes 1 second to run, turning it into a function would make that same code take about 1.00002 seconds to run with the bonus of being reusable to boot. Worrying about 0.00002 seconds is a waste of time and is premature optimization.
....
....
....
The bigger the chunk of code is, the more likely you'll make it a function. As the chunk of code grows, function call overhead means less and less. Optimizing small functions is the job of inline and macros.
the first point there is that a function makes it reusable, then you say that optimizing small functions is the job of inline keywords and macros ... which by definition aren't functions and are just abstractions for .... inlining code.
So in perfect English you're saying, don't inline code it makes code less DRY (don't repeat yourself), instead use inline abstractions. I would have to agree with that. However, this further proves my points because at the end of the day, it is inline.
Also, inline is a recommendation to the compiler, nothing more, nothing less. It's more common then not that even good optimizing compilers will disregard such keywords and forcefully not inline functions, especially in the case of recursion even when you compile with force inlining flags. Which is why i'm a fan of and avid user of macros instead.
"If art interprets our dreams, the computer executes them in the guise of programs!" - SICP

“If at first, the idea is not absurd, then there is no hope for it” - Albert Einstein