Speeding up plotting widget

Uwe Thiem uwix at iway.na
Tue Jun 10 08:46:03 BST 2008


On Monday 09 June 2008, John Tapsell wrote:
> Hi all,
>
>   I'm trying to improve the plotting widget thing in the kde system
> monitor (aka ksysguard).  Basically it draws white background,
> horizontal/vertical lines, and then plots the cpu usage etc lines
> on top.
>
>   I am finding that this is taking around 30% of the CPU, which
> makes it kinda useless for monitoring what the cpu usage is :-D
>
>   The reason for it being slow is not obvious to me.
>
> If I draw just a white background, it takes 1% CPU usage.
> If I draw a white background + _dashed_ horizontal lines  (updating
> twice a second), it takes up 10% CPU time  (on dual core.  so 20%
> of one CPU).
> If I draw a white background + _straight_ horizontal lines 
> (updating twice a second), it takes up 1% CPU time
>
>
>
> There seem to be other reasons as to why it's slow, but this seems
> to be a good place to start.  Why would drawing dashed lines be so
> slow? (It's about 10 horizontal lines, stretching across my screen
> (so about 1000 pixels long).
>
> How can I try to speed this up?

30% CPU seems to indicate that something is wrong. Still, just for 
speeding it up:

1.
Create a buffer at startup. Height is the line thickness. Width is the 
width of your widget. Plot the line in the buffer once.

2.
bitBlt the buffer over into the widget instead of plotting in the 
widget.

3.
Catch resize events and adjust your buffer.

This should be much faster.

Uwe

-- 
Ignorance killed the cat, sir, curiosity was framed!




More information about the kde-core-devel mailing list