1. Inline vs. Function
- Posted by "C. K. Lester" <cklester at yahoo.com> Mar 18, 2002
- 396 views
Rob, I can't remember... Is inlining code much faster than calling it as a function? I wouldn't think there'd be much speed loss in turning chunks of code into a function... ?
2. Re: Inline vs. Function
- Posted by euman at bellsouth.net Mar 18, 2002
- 388 views
Inlining code is faster CK. Euman euman at bellsouth.net
3. Re: Inline vs. Function
- Posted by Robert Craig <rds at RapidEuphoria.com> Mar 18, 2002
- 398 views
C.K. Lester writes: > Rob, I can't remember... Is inlining code much faster than calling it as > a function? I wouldn't think there'd be much speed loss in turning > chunks of code into a function... ? On my machine, the code below shows that if incrementing an integer variable by 1 costs 1 unit, then a call with no arguments to a procedure costs about 14 units. I imagine that additional arguments would cost a few units each. Whether you in-line or not, depends on how often you call the routine, how small the routine is, how much work is performed per call, how badly you want to speed things up, etc. There is no simple rule. There are also second-order effects, like caching. Having one copy of a piece of code in a routine may give you better caching, than having 20 copies of that code scattered around your program. procedure foo() end procedure atom t integer x t = time() for i = 1 to 100000000 do foo() end for ? time()-t x = 0 t = time() for i = 1 to 100000000 do x = x + 1 end for ? time() -t t = time() for i = 1 to 100000000 do -- overhead of empty loop - subtract this from the above times end for ? time() -t Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
4. Re: Inline vs. Function
- Posted by Kat <gertie at PELL.NET> Mar 19, 2002
- 410 views
On 18 Mar 2002, at 20:16, euman at bellsouth.net wrote: > > Inlining code is faster CK. Depending on if the compiler or interpreter actually inlines it or treats it as a function containing machine code. Plus, you haveto account for your 16bit code, if you use 16bit, using cpu time to thunk 32-16-32 again. Then comes call-proc-with-pointers. then call-func-with-pointers. then call proc-with-data. then call-func-with-data. then comes overlays. At least, that's what i discovered in Pascal. then comes mutexes? then comes RPC over a LAN. Kat
5. Re: Inline vs. Function
- Posted by euman at bellsouth.net Mar 19, 2002
- 408 views
This from the infamous Euphoria Performance Tips html In-lining of Routine Calls If you have a routine that is rather small and fast, but is called a huge number of times, *you will save time* by doing the operation in-line, rather than calling the routine. Your code may become less readable, so it might be better to in-line only at places that generate a lot of calls to the routine "Robert said that this only make your code less readable not that using function calls are faster cause they arent" Who uses 16 bit code in Euphoria Kat? Who thunks Euphoria code? (no one I know cause theres no need) besides, this is Euphoria not Pascal Euman euman at bellsouth.net ----- Original Message ----- From: "Kat" <gertie at PELL.NET> To: "EUforum" <EUforum at topica.com> Sent: Monday, March 18, 2002 11:05 PM Subject: Re: Inline vs. Function > > On 18 Mar 2002, at 20:16, euman at bellsouth.net wrote: > > > > > Inlining code is faster CK. > > Depending on if the compiler or interpreter actually inlines it or treats it > as a > function containing machine code. Plus, you haveto account for your 16bit > code, if you use 16bit, using cpu time to thunk 32-16-32 again. > > Then comes call-proc-with-pointers. > then call-func-with-pointers. > then call proc-with-data. > then call-func-with-data. > then comes overlays. > At least, that's what i discovered in Pascal. > > then comes mutexes? > then comes RPC over a LAN. > > Kat > > > >