[Qt-interest] Faster logfile viewer

Malyushytsky, Alex alex at wai.com
Wed Aug 5 02:10:55 CEST 2009


The problem you are facing is caused by the repaint calls.
If I were you, I would try to reconsider the requirements you apply:

>> The resulting requirements are:
>> - Because one does not know when the next line has to be shown one cannot
>> merge several lines together and has to show each one separately.
>> - Because each line can be the last one for a longer time the widget has to
>> be updated after each line.

As something like:
- since repainting the whole widget after adding each line means recalculating widget layout, and  slows down code significantly,
make the code to limit updating to "N" times per second.

How to do it?
Using the example code provided, I will try to suggest:

setUpdatesEnabled(false) each time you before you add new line.
Use QTimer to call the update when expired (setUpdatesEnabled(true) should be enough).
If timer is already active change interval to initial ("N" times per second).

I think this should fix the problem you have.
And maximum delay between document modification and graphical update should not be longer than N.

In addition, if you want "log" file you might want to set QTextDocument's maximumBlockCount property to limit the number of paragraphs (lines in your case). This might not to speed up your code, but will insure that not more than  n lines is shown in the QTextedit.

Regards,
   Alex




-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Christoph Bartoschek
Sent: Tuesday, August 04, 2009 3:58 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Faster logfile viewer

Arnold Krille wrote:

> 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.

Hi,

unfortunately using update() does not work. I have to explain the
application a little bit more:

It's a VLSI-application that executes operations that take several hours of
runtime during which the GUI is effectively blocked. There is only the
TextEdit with the logfile where the operations write status information to.
Normally this works fine but sometimes the operations want to write more
than 100000 lines in a very short time.

The resulting requirements are:

- Because one does not know when the next line has to be shown one cannot
merge several lines together and has to show each one separately.
- Because each line can be the last one for a longer time the widget has to
be updated after each line.

Our old GUI uses Motif and also colored lines. The updates are also after
each line but writing 10000 lines takes less than one second.

Christoph
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list