[Qt-interest] QFont::defaultFamily() takes ridiculous share of CPU time, but only on Windows

Harri Pasanen grego at mpaja.com
Thu Apr 7 16:20:38 CEST 2011


Why don't you just install Qt sources and step into QFont::defaultFamily() to 
see what it does?

I've often used that recipe with great success, and it is usually faster than 
waiting for somebody to answer...

Just my 2 cents.

Harri

Thursday, April 07, 2011 02:28 pm 
Philipp Münzel writes:
> Hi folks,
> 
> I develop an application that renders a lot of bitmaps with text on them.
> 
> This works roughly like this:
> QImage image;
> QPainter painter;
> painter.begin(&image);
> QFont mono_8("Inconsolata", 8);
> QBrush brush(QColor(r,g,b), Qt::SolidPattern);
> 
> QPainterPath path;
> path.addText(x, y, mono_8, text);
> painter.fillPath(path, brush);
> 
> painter.end();
> 
> Each rendering consists of about 50 to 100 words.
> 
> The result is reasonably fast on Linux.
> On Windows, however, performance is rather bad.
> 
> I used Intel VTune as a profiler to see what is consuming the CPU time.
> I found that on Windows, 50% (!!!) of the CPU time is spent in the function
> QFont::defaultFamily(). What is this?
> When I profile on Linux, I see pretty much the result I expected, most of
> the time is consumed by the QPainterPath::addText() function.
> 
> What's the QFont::defaultFamily() function doing? Why does it take such an
> enormous amount of CPU time on windows, where on Linux, I don't even find
> it in the top 100 functions of my profiling? How and why gets
> QFont::defaultFamily() called in the scenario described above?
> 
> 
> Regards,
> Philipp
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list