what are the advantages and disadvantages of inline function.
Answers
Answered by
4
Inline function is the optimization technique used by the compilers .
Advantages :-
1) It does not require function calling overhead .
2) It also save overhead of variables push on the stack , while function calling .
3) It also save overhead of return call from a function .
4) It increases locality of reference by utilizing instruction cache .
5) After in-lining compiler can also apply intra procedural optmization if specified . This is the most important one , in this way compiler can now focus on dead code elimination , can give more stress on branch prediction , induction variable elimination etc .
Disadvantages :-
1) May increase function size so that it may not fit on the cache , causing lots of chance miss .
2) After in-lining function if variables number which are going to use register increases than they may create overhead on register variable resource utilization .
3) It may cause compilation overhead as if some body changes code inside inline function than all calling location will also be compiled .
4) If used in header file , it will make your header file size large and may also make it unreadable .
5) If somebody used too many inline function resultant in a larger code size than it may cause thrashing in memory . More and more number of page fault bringing down your program performance .
6) Its not useful for embedded system where large binary size is not preferred at all due to memory size constraints .
Hope it helps !!
Shreya ❤
Advantages :-
1) It does not require function calling overhead .
2) It also save overhead of variables push on the stack , while function calling .
3) It also save overhead of return call from a function .
4) It increases locality of reference by utilizing instruction cache .
5) After in-lining compiler can also apply intra procedural optmization if specified . This is the most important one , in this way compiler can now focus on dead code elimination , can give more stress on branch prediction , induction variable elimination etc .
Disadvantages :-
1) May increase function size so that it may not fit on the cache , causing lots of chance miss .
2) After in-lining function if variables number which are going to use register increases than they may create overhead on register variable resource utilization .
3) It may cause compilation overhead as if some body changes code inside inline function than all calling location will also be compiled .
4) If used in header file , it will make your header file size large and may also make it unreadable .
5) If somebody used too many inline function resultant in a larger code size than it may cause thrashing in memory . More and more number of page fault bringing down your program performance .
6) Its not useful for embedded system where large binary size is not preferred at all due to memory size constraints .
Hope it helps !!
Shreya ❤
Answered by
1
Answe :1] function call overhead doesn't occur
2] it also saves the overhead of push/pop variables on the stack when function is called
3] it also saves overhead of return call of function
Similar questions
Social Sciences,
4 months ago
Physics,
4 months ago
Chemistry,
4 months ago
Math,
9 months ago
Math,
9 months ago
English,
1 year ago
Social Sciences,
1 year ago