[PyQt] Creating widget drawing benchmark test

Andreas Pakulat apaku at gmx.de
Sat Apr 25 02:08:52 BST 2009


On 24.04.09 17:02:35, Brent Villalobos wrote:
> Has anyone written a widget draw-time benchmarking program?  I need to  
> write a test that will provide an idea of how PyQt performs with a large  
> number of widgets.  I'm thinking of writing an application that creates  
> a grid of QPushButton widgets.  The test then runs when someone pushes a  
> "Go" button which calls a function that hides and shows each button.  It  
> would look something like this:
>
>    def refresh():
>        startTime = time.time()
>        for i, b in enumerate(buttons):
>            b.hide()
>            b.show()
>        print "Hide/show buttons in %f seconds" % (time.time()-startTime)
>
> Is this a good test or am I not really testing what I think I'm testing?  

With that you're testing how fast a QWidget can set its internal state
variables from hidden to shown. You don't test any painting performance.
If you want to do that, you'll probably have to either

- patch Qt
- or write a subclass of QPushButton which overrides paintEvent() and
  then times how long a call to the base class implementation needs.

And then you should do just either a hide or a show, as doing both might
simply be discarded due to how the event queue works.

Andreas

-- 
In the stairway of life, you'd best take the elevator.


More information about the PyQt mailing list