PDA

View Full Version : Slow performance with many QGraphicsItems



abbb
23rd December 2015, 03:34
Hi,

I'm trying to create an LED panel that consists of a 96x64 grid of "LEDs" for a total of 6144 items. I plan on updating all of the LED colors every 15ms.

I've added a QGraphicsEllipseItem to the scene for each LED. I've also made the view scale with the window size. The problem I'm having is with the time it takes to change the item colors. The problem gets worse when I maximize the window, which increases the view size and the time it takes for an update.

I've read that having this many items in the scene generally isn't a good idea due to the overhead from the paint call for each item. So I tried creating a custom QGraphicsItem for the entire LED panel, using its paint method to paint all of the LEDs at once, but this didn't help much with the performance.

What would be the best method for having this many items in the scene update every 15ms? Any ideas on how to improve the performance?

Thanks!

anda_skoa
23rd December 2015, 10:03
That is more likely a problem of the update rate than the number of items.

The 10000 chips example can easily display 10000 "microchip" items in several views in parallel.

If the panel is the only thing you are displaying you could try creating a custom widget for it instead of using QGraphicsView.

You could also measure if drawing rectangles instead of ellipses is faster, in which case you could do that and apply a mask to "cut out" ellipses.

Cheers,
_

abbb
24th December 2015, 00:19
Thanks for the help.

I was able to get the update rate down to around 6ms.

Drawing rectangles instead of ellipses cut down the time significantly. I also was mistakenly using a pen while drawing all of the items in my paint method, which took up a lot of time.

d_stranz
24th December 2015, 04:08
I was able to get the update rate down to around 6ms.

You realize that this is far faster than the human eye can follow, and faster than the refresh rate of most monitors, so what's the point? Human eyes are typically not much better than 30 Hz (33 ms) and monitors often aren't much better than that. So in fact while you may be processing your events at 160 Hz, you certainly aren't displaying the changes that quickly.

abbb
24th December 2015, 08:03
You realize that this is far faster than the human eye can follow, and faster than the refresh rate of most monitors, so what's the point? Human eyes are typically not much better than 30 Hz (33 ms) and monitors often aren't much better than that.

I disagree with that. Speaking from personal experience, I can definitely tell the difference between 60Hz and 120Hz. I bought a 120Hz monitor a while back and wanted to test it out to see if it made any difference, so I had someone else switch the mode of the monitor between 60 and 120Hz without me knowing which mode it was in, and the difference was immediately noticeable. Animations look much "smoother" at the higher rate.

Here's a website where you can compare different frame rates: https://frames-per-second.appspot.com/. The differences are most noticeable when there is no motion blur.


So in fact while you may be processing your events at 160 Hz, you certainly aren't displaying the changes that quickly.

Right, but I wanted to make sure I had enough time to both update all of the LEDs and do other processing within a 15-16ms time period (I plan on giving the panel a new frame to display at 60Hz). I'll have more time to do other processing if it takes less time to update the LEDs.

d_stranz
24th December 2015, 16:57
I disagree with that.

And so do I, now that I've done some googling... (http://whisper.ausgamers.com/wiki/index.php/How_many_FPS_human_eye_can_see) I guess I am one of those who is guilty of spouting crap:


...the short answer is, the human eye / brain combination can see well over 100 frames per second and thus far the limits have not thoroughly been tested yet. Suffice it to say, IT IS NOTHING LIKE THE 24, 30, 60 or even 100 fps crap, that gets spouted on the Internet.

That's the trouble with having been brought up in the CRT age.