Re: gdmgreeter CPU usage



Am Mittwoch, 11. Januar 2006 19:44 schrieb Federico Mena Quintero:
> - Given the same parameters, does the function always return the same
> value?  I don't want to put in a cache prematurely, but this would be
> useful to know.
Basically yes, but it depends on your installed fonts, the current locale (of 
the web page in the firefox case). And the parameter is comparable to a SQL 
query, so caching isn't exactly straightforward - but of course doable.

>
> - Can we get a little program that runs FcFontSort in a loop so that we
> can profile it?

You don't need to run it in a loop if you have a profiler - it takes long 
enough ;)

fc-match --sort 'sans serif' will do.

If you want a loop, go for

     FcPattern *pat = FcPatternCreate ();

    FcConfigSubstitute (0, pat, FcMatchPattern);
    FcDefaultSubstitute (pat);
    FcResult    result;

    for (int i = 0; i < 20000; i++) FcFontSort (0, pat, FcTrue, 0, &result);

The FcPattern is the one to cache on and that is basically a list of weak or 
strong conditions for the font to find. You could calculate a cache value for 
that, but I'm afraid reading that cache in on every application startup isn't 
exactly cheap either. But as I said early, it highly depends on the number of 
installed fonts. It will be worth it for everyone having > X fonts installed, 
while it may be more expensive to cache for someone with < X fonts (where X 
of course depends on your implementation of the caching).

Greetings, Stephan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]