[Qt-interest] Faster logfile viewer
Arnold Krille
arnold at arnoldarts.de
Tue Aug 4 22:20:35 CEST 2009
Hi,
On Tuesday 04 August 2009 19:24:08 Christoph Bartoschek wrote:
> consider the program at the end of the post. It shows a TextEdit and a
> PushButton. When you press the button 10000 lines are appended to the
> TextEdit and the view is updated. The whole procedure takes 47 Seconds on
> my machine.
> Our old Motif application does the same within less then a second. How can
> I get a performace that is comparable to our old application with Qt?
Without testing the code (yet) By default the QTextEdit has richtext enabled,
which can make your log nicely colored but also adds some overhead.
And after actually running your app (pretty slow here) and running it inside
callgrind (a lot slower!) I see:
You are calling repaint() which executes an immediate repaint. You should call
update() which schedules the paintEvents in the event-loop.
Replacing the repaint() with update() reduces the runtime significantly (in
callgrind) and results naturally in much lower costs and only one effective
paintEvent.
In practice this change will not be a problem because normally the log-
messages are coming distributed over time and there will be enough time to do
a paintEvent every now and then.
Unless you really want a log-_file_-viewer but in that case it should be far
simplier to load the file as whole into the widget. Or at least in large
chunks, not line by line.
Have fun,
Arnold
PS: If you are interested I can send you the callgrind-files so you can take a
look at them for yourself (for example with kcachegrind).
PPS: callgrind is a great tool for speed-optimizations in larger blocks of
code where the benchmarks of the qt-testlib are not usable anymore...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090804/7c8ba5fc/attachment.bin
More information about the Qt-interest-old
mailing list