On Sun, Jul 22, 2007 at 01:44:35PM +0200, [EMAIL PROTECTED] wrote:
> Selon [EMAIL PROTECTED]:
> > Selon Guillaume Pothier <[EMAIL PROTECTED]>:
> >
> > > >
> > > > Make sure the profiler runs a little bit longer. 20 seconds cumulative
> > > > or so. With 4.74 seconds there's a lot of statistical noise.
> > > >
> > >
> > > Done, now 23s.
> > > I updated the file at the same URL:
> > > http://www.dcc.uchile.cl/~gpothier/gprof.out
> 
> One question: are you sure that your Qt is compiled with optimisation and 
> debug
> disabled? I've read somewhere that it makes a big difference (similar to the
> stdlib_debug one). Looks like the QHash searching takes a lot... Same question
> for your boost installation.

Looks like we can shave off 3.5% as

[27]     9.2    0.55    1.61 44157897 
lyx::frontend::GuiFontMetrics::width(wchar_t) const [27]
                1.61    0.00 88316089/89786389     QHash<wchar_t, 
int>::findNode(wchar_t const&, unsigned int*) const [31]
                0.00    0.00      16/21          QHash<wchar_t, 
int>::detach_helper() [1984]

looks into the hash twice. The code is

        int GuiFontMetrics::width(char_type c) const
        {
                if (smallcaps_shape_)
                        return smallcapsWidth(c);

                if (!width_cache_.contains(c)) {
                        if (is_utf16(c))
                                width_cache_.insert(c, 
metrics_.width(ucs4_to_qchar(c)));
                        else
                                width_cache_.insert(c, 
metrics_.width(toqstr(docstring(1,c))));
                }

                return width_cache_.value(c);
        }


Something like

        int GuiFontMetrics::width(char_type c) const
        {
                if (smallcaps_shape_)
                        return smallcapsWidth(c);

                int w = width_cache_.value(c, WHATEVER);
                if (w != WHATEVER)
                        return w;

                if (is_utf16(c))
                        w = metrics_.width(ucs4_to_qchar(c);
                else
                        w = metrics_.width(toqstr(docstring(1, c));  // ***

                width_cache_.insert(c, w);
                return w;
        }

should do.

And, of course, the line marked *** does not look overly efficient as
well.

Andre'

PS: Nice profile now, Guillaume.

Reply via email to