Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Speeding code

Author: Slater Wold

Date: 09:57:24 05/12/03

Go up one level in this thread


Stole from some website:

"By declaring a function `inline', you can direct [compiler] to integrate
that function's code into the code for its callers.  This makes
execution faster by eliminating the function-call overhead; in
addition, if any of the actual argument values are constant, their known
values may permit simplifications at compile time so that not all of the
inline function's code needs to be included.  The effect on code size is
less predictable; object code may be larger or smaller with function
inlining, depending on the particular case.  Inlining of functions is an
optimization and it really "works" only in optimizing compilation.  If
you don't use `-O', no function is really inline."




On May 12, 2003 at 11:48:44, Fermin Serrano wrote:

>What does "inline" exactly mean? I am spanish and don't know the meaning. I have
>look at it in my dictionary (bad dictionary as I have discovered) and have not
>found.
>thx
>
>On May 12, 2003 at 11:39:02, Uri Blass wrote:
>
>>On May 12, 2003 at 10:38:57, Fermin Serrano wrote:
>>
>>>Programming my engine I have same doubts (many, only post same concerning
>>>speed):
>>>	Question 1:
>>>	-----------------
>>>	I would like to know how jumps can slow down my engine. I mean, if I have a
>>>function like this:
>>>
>>>	int eval () {
>>>		r1 = {	code to analyze knight position 	}
>>>		r2 = {	code to analyze bishop			}
>>>		etc
>>>		return r1[side]-r1[c_side]+r2[side]-r2[c_side]+ .... etc
>>>	}
>>>
>>>	if I replace r1 = eval_knight_position(), r2=eval_bishop_position(), etc....
>>>how many could this slow down the code? I think this obviously is slower because
>>>it add jump and stack code, but is better in terms of clarity and code
>>>organization... so I want to know the speed efects and know when to apply
>>>functions calls or paste same code.
>>
>>You can inline the functions so there is no demage of writing functions.
>>The compiler should be able to translate it to the right code.
>>
>>I assume that you use C or C++ in this post.
>>
>>Uri



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.