how fast is inline functions....if the function is really small like
return a*b;
a split second....? or faster...i really want to know..thanks
how fast is inline functions....if the function is really small like
return a*b;
a split second....? or faster...i really want to know..thanks
An inline function is simply a function that does not involve a function call.
The first function (assuming a non-optimizing compiler) will have to push arguments onto the stack and call a function, whereas the second will be 'expanded' into the 'calling' code.. but there will be no actual function call, no messing with the stack. Inline doesn't make a function fast, it just doesn't add the overhead of a function call.Code:int mul_slow(int a, int b) { return a * b; } inline int mul(int a, int b) { return a * b; }
As for the speed, try it on your own compiler. You will be able to call line functions more than a million times a second, so that's probably less than a split second (for definitions of split second which have duration greater than a microsecond ).
>how fast is inline functions
The execution time of inline functions are unque to the function and the compiler that runs it, do some profiling to get an idea of the execution time on your compiler.
-Prelude
My best code is written with the delete key.
Assuming a and b are some primative data type number ( as opposed to some complicated class ) then a * b will only take a very small fraction of a second to complete, and being that your function is inline no overhead of a function call and return will be added.Originally posted by nextus
a*b;
a split second....? or faster...i really want to know..thanks [/B]