What do I gain from defining a [small] function as inline?
Thanks
R
|
|
0
|
|
|
|
Reply
|
inuY4sha1 (12)
|
4/8/2008 2:41:59 PM |
|
Sorry ... I should have googled a bit ...
InuY4sha ha scritto:
> What do I gain from defining a [small] function as inline?
> Thanks
> R
|
|
0
|
|
|
|
Reply
|
inuY4sha1 (12)
|
4/8/2008 2:49:09 PM
|
|
"InuY4sha" <inuY4sha@email.it> wrote in message
news:75a8e19a-2407-4c27-b767-978da923f0dd@i36g2000prf.googlegroups.com...
> What do I gain from defining a [small] function as inline?
> Thanks
>
Usually nothing. With optimisation set high, a decent compiler will do this
for you.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm
|
|
0
|
|
|
|
Reply
|
regniztar (3128)
|
4/8/2008 2:50:54 PM
|
|
On Tue, 8 Apr 2008 07:41:59 -0700 (PDT)
InuY4sha <inuY4sha@email.it> wrote:
> What do I gain from defining a [small] function as inline?
> Thanks
> R
In case you haven't found the answer you were looking for, I'll give it
a shot:
Calling a function has a (small) amount of overhead to it: things
(i.e., return address and function arguments) need to be pushed and
popped off of the stack, and jumps need to be made to different points
in the program.
If a function is "sufficiently" small (only a few lines), then the
overhead of actually calling a function may become a significant
portion of the function's execution time.
By inline'ing the function, a copy of the functions body is compiled
in-place wherever it is called in the program, thus eliminating the
actual call during runtime, and *maybe* getting small performance
increase.
As Malcolm said, this is usually one of the optimizations a compiler
will do automatically for you, but hopefully now you have a better
understanding of why it does it.
D. Webb
|
|
0
|
|
|
|
Reply
|
devnull431 (1)
|
4/8/2008 5:07:04 PM
|
|
On Apr 8, 1:07=A0pm, "D. Webb" <devnull...@yahoo.com> wrote:
> On Tue, 8 Apr 2008 07:41:59 -0700 (PDT)
>
> InuY4sha <inuY4...@email.it> wrote:
> > What do I gain from defining a [small] function as inline?
> > Thanks
> > R
>
> In case you haven't found the answer you were looking for, I'll give it
> a shot:
>
> Calling a function has a (small) amount of overhead to it: things
> (i.e., return address and function arguments) need to be pushed and
> popped off of the stack, and jumps need to be made to different points
> in the program.
>
> If a function is "sufficiently" small (only a few lines), then the
> overhead of actually calling a function may become a significant
> portion of the function's execution time.
>
> By inline'ing the function, a copy of the functions body is compiled
> in-place wherever it is called in the program, thus eliminating the
> actual call during runtime, and *maybe* getting small performance
> increase.
>
This is not required at all. According to section 6.7.4 of the
standard "Making a function an inline function suggests that calls to
the function be as fast as possible. The extent to which such
suggestions are effective is implementation-defined." In other words
inline may do as you suggest. It may also perform some other form of
optimization to increase the speed of the function. It may only
perform optimizations for some of your inline functions based on some
criteria defined by the implementer. It it may in fact do nothing at
all.
|
|
0
|
|
|
|
Reply
|
swengineer001 (71)
|
4/9/2008 2:28:52 AM
|
|
|
4 Replies
32 Views
(page loaded in 0.376 seconds)
Similiar Articles: Inline image samples - comp.text.pdfHullo. I'm adding support for parsing inline images in graphics streams to my fledgling PDF library. I've only managed to find one file which uses th... icc inline assembly - comp.lang.asm.x86icc inline assembly - comp.lang.asm.x86 Inline Assembly, use-msasm and fasm-blocks - Intel® Software Network Intel C++ compiler also supports Microsoft style inline ... Intel C++ Compiler (Linux x86_64) - "GNU-style Inline Assembly ...Hello, Could anyone suggest some resources freely available to - understand, interpret, analyze and write "GNU-style Inline Assembly" on Linux x86_6... MinGW and Inline Assembler - comp.os.ms-windows.programmer.win32 ...Hello, this is part of a CPU-Speed-Detection Program: #ifdef __BORLANDC__ void getRdtsc( UINT64* pResult ) { _asm { db 0... help with inline asm() - comp.unix.solarisI have what I think is a relatively clean "atomic inc" routine, that appears to work fine. Only trouble is, 'CC' wont compile it because it complains ... Gfortran reort on subroutine inlining? - comp.lang.fortran ...Regarding inlining: Except for internal functions, GCC < 4.6 did not do much inlining; this has changed with GCC 4.6, which should inline much more functions - which ... Are newbie questions OK in here? - comp.lang.asm.x86If yes, then I will have questions that involve more than the syntax. Things like, well I'll just ask one. Microsoft has eliminated the inline assem... make a div disappear after a few seconds - comp.lang.javascript ...Hi all, I've created a DIV with important notes for my site. I've a Close button on it, but would like to have a timer that automatically close the ... Help with fplot function - comp.soft-sys.matlabHey Walter,thanks for reply I'm quite new to matlab but looked up using the inline command. I can only get it to take 'x' as the variable, instead of defining 't' as ... Condition Code - comp.lang.asm.x86hi all this example shows use of gcc inline assembly in second example there is a constraints name : Condition Code i have no mean difference to use... InlineBased in Birmingham, Alabama and with fully staffed offices in Montgomery, Alabama and Jackson, Mississippi, InLine offers the most robust and complete set of ... Inline Distributing Environmental Remediation and Building InformationInline Distributing is one of the largest suppliers of lead remediation, asbestos remediation and removal and environmental restoration products in the U.S. Featuring ... Inline | Define Inline at Dictionary.comadjective (of an internal-combustion engine) having the cylinders ranged side by side in one or more rows along the crankshaft. Cheap Inline Skates www.target.com ... Welcome to Inline, Inc.Welcome to the Web site for INLINE, Inc., manufacturer of high resolution video products and advanced audiovisual system integration tools. Inline function - Wikipedia, the free encyclopediaIn various versions of the C and C++ programming languages, an inline function is a function upon which the compiler has been requested to perform inline expansion. 6/19/2012 6:26:22 AM
|