Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2001:
[Freeciv-Dev] Re: chance of winning a battle
Home

[Freeciv-Dev] Re: chance of winning a battle

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: chance of winning a battle
From: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxxxx>
Date: Sat, 21 Jul 2001 21:10:47 +0300 (IDT)

On Sun, 15 Jul 2001, Gaute B Strokkenes wrote:
> 
> Has anyone done any profiling to make sure that this is the case, and
> if so would they like to share the results with the rest of us?

ok I did some profiling (not too much, couple of turns, took 2 cities or
so, 6 AI players, server and client on the same machine) and here are some
results:

the top of the pop is...
     *applause*
normalize_map_pos from common/map.c with 10.84% of the votes
     *big applause*

the reason being it's called lots of times and is not optimal,
attached is the patch that reduces the relative time to 4.54%
and, I think, makes the function a bit safer.
we can do a bit better, substituting "if" for "while" on 2 occasions but
it's unsafe (kind of assumes that we cannot go too far off the map).

patch is against CVS from 21 July

the function win_chance comes at 0.93% of the time which is quite high but
not crucial.  problems might arise in the future, when more complicated AI
will call win_chance more often, when planning a whole campaign or
something.

while freely browsing the source I also discovered that dir_ok is
implemented in an ugly way.  it's completely unneccessary to improve it
(with 0.00% of the usage) but might do it later all the same.

if anybody wants the profiling data file (for gprof), shout.  It's mere
300K so I can send it anytime :)

G.

Attachment: normalize_map_pos.diff
Description: Text document


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