[Freeciv-Dev] Re: gtk clients: translate_menu_path
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Thu, 16 Oct 2003, Jason Short wrote:
> --On Thursday, October 16, 2003 3:58 PM +0100 Vasco Alexandre Da Silva
> Costa <vasc@xxxxxxxxxxxxxx> wrote:
>
> > On Thu, 16 Oct 2003, Per I. Mathisen wrote:
> >
> >> I just read an old profile of the gtk2 client done by Thomas, and I
> >> noticed that 18% of CPU time was spent inside translate_menu_path(). This
> >> is a function that is called once every menu item every turn, at least.
> >>
> >> It is a quite expensive function. Is it not possible to make this
> >> function calculate the result once only, and cache it? Surely the result
> >> does not change throughout the game for the same set of input. How about
> >> putting the translated string into hashlist, for instance?
> >> Alternatively, we could the uses of it turn it into a macro, and make
> >> some fancy use of static strings to hold this data. This would be even
> >> faster.
> >
> > I can make it faster, but I doubt it is what is making the unit moves
> > slower.
>
> Actually it could be. The new flush code passes control back to gdk during
> each flush, and gdk may do other updates as well. It's possible that it
> re-translates the menu during this time.
>
> That might explain why I've never been able to reproduce this problem...
Well it is 98% as fast as it could be now. The heavy function is only
run once at game startup instead of everytime the menus require some changing.
The reason why I say is not the problem, is that the GTK+ 1.2 client has
always used that heavy function. Albeit using strtok() instead of my
special menu_path_tok() function, which should not be heavier than strtok().
Also, that code is identical in S1_14 and it seems S1_14 is not as slow as
HEAD. Or is it as slow as HEAD?
---
Vasco Alexandre da Silva Costa @ Instituto Superior Tecnico, Lisboa
[Freeciv-Dev] Re: gtk clients: translate_menu_path, Vasco Alexandre Da Silva Costa, 2003/10/17
|
|