Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: inlining functions
Home

[Freeciv-Dev] Re: inlining functions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: inlining functions
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 20 Aug 2001 23:17:50 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Fri, Aug 17, 2001 at 08:03:50PM -0400, Jason Dorje Short wrote:
> I looked over previous discussions about inlining functions, and I think
> inlining functions is better.
> 
> An inlined function should be as fast as a macro.  Although this may not
> be the case for all compilers, we should let the compiler people worry
> about it.

I took Ross's autogame, the current cvs version and these commands:

-------
hard
set aifill 7
set timeout -1
set seed 42
set randseed 42
set endyear -1000
create foobar
start
-------

I also enabled profiling. The profile data vary a lot the overall
times however are almost constant:

user    1m9.800s
sys     0m0.160s

user    1m9.670s
sys     0m0.120s

user    1m9.870s
sys     0m0.120s

user    1m9.900s
sys     0m0.120s

user    1m9.910s
sys     0m0.110s

user    1m9.710s
sys     0m0.140s

Size: 1908979 Aug 20 19:24 server/civserver*

For the next steps I choose map_get_city().

Inlining with "-Winline -finline-functions" and putting a "extern
inline" map_get_city() in map.h:

user    1m1.270s
sys     0m0.110s

user    1m1.200s
sys     0m0.120s

user    1m1.300s
sys     0m0.730s

user    1m1.260s
sys     0m0.190s

user    1m1.140s
sys     0m0.240s

user    1m1.120s
sys     0m0.450s

Size: 2207226 Aug 20 20:08 server/civserver*

Normal compile with map_get_city() in map.h as "#define
map_get_city(x,y) ((map.tiles + map_adjust_x(x) +
map_adjust_y(y)*map.xsize)->city) ":

real    1m21.483s
user    1m8.670s
sys     0m0.150s

real    1m18.761s
user    1m8.630s
sys     0m0.150s

real    1m26.293s
user    1m8.890s
sys     0m0.420s

real    1m22.557s
user    1m8.390s
sys     0m0.140s

real    1m29.580s
user    1m8.860s
sys     0m0.140s

real    1m19.064s
user    1m8.480s
sys     0m0.150s

Size: 1921042 Aug 20 22:06 server/civserver*

From the timing and the size it looks like the macro isn't expanded in
all possible cases OR gcc is also inlining other methods by using
"-Winline -finline-functions". Looking at the gcc manual it looks like
the latter is true. So what options have to be passed to gcc to just
inline the functions which are marked inline?

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  "Heuer's Law: Any feature is a bug unless it can be turned off."


[Prev in Thread] Current Thread [Next in Thread]