[Qt-jambi-interest] QPixmap erratic performance

Gunnar Sletta gunnar at trolltech.com
Mon Nov 17 11:34:51 CET 2008


Bart van Deenen wrote:
> On Monday 17 November 2008 10:09:51 Bart van Deenen wrote:
> 
>  > On Monday 17 November 2008 09:54:38 Gunnar Sletta wrote:
> 
>  > > > Ok. I'm starting to get somewhere. I've added instrumentation to the
> 
>  > > > code (not shown here) which uses System.currentTimeMillis() to 
> measure
> 
>  > > > intervals, and it turns out that the interval between two consecutive
> 
>  > > > calls to timerEvent is very erratic! My 'render' function (currently
> 
>  > > > with a much simplified QPixmap tree under it) only takes a few 
> ms. The
> 
>  > > > QTimer is supposed to run at 40 ms interval, but the actual intervals
> 
>  > > > are anywhere between 15 and 300 ms!
> 
>  > >
> 
>  > > A timer tries to fire as close to, but at least 40 ms after the last
> 
>  > > one, but there are no guarantees. I've never seen such behaviour, so I
> 
>  > > would have to see your code to know more
> 
>  >
> 
>  > I'm simplifying the code to narrow it down to where the problem 
> occurs, and
> 
>  > then I'll post it. Thanks for thinking along.
> 
>  >
> 
>  > Bart
> 
> I've narrowed down my source code to something simple. Unfortunately, 
> now the erraticness is gone! It seems to have to do with the number or 
> size of QPixmaps I'm using to draw my main QPixmap :-(
> 
> Here's my non-erratic code. The only difference with my problem code is 
> that the 'render' function here consists of one QPixmap being drawn into 
> my root object, and that with the trouble code there's a lot of QPixmaps 
> rendering into each other, and finally being combined into the root 
> QPixmap. The problem is not the overal time it takes to do the 
> rendering; with a simplified tree of objects that is consistently below 
> 5 ms. I don't understand where the problem is starting to occur :-(. 
> Next I'll add some more of my 'sprite_object's to see if it's the number 
> or size of them that matters.

There is also the fact that the precision of System.currentTimeMillis() 
is system dependent. On windows its precision is ~17ms on Linux I 
believe it is between 1 and 5ms, so you also have to factor that into 
benchmarks and run enough iterations for the precision to be of no 
consequence.

best regards,
Gunnar



More information about the Qt-jambi-interest mailing list