Results 1 to 6 of 6

Thread: Slow performance with many QGraphicsItems

  1. #1
    Join Date
    Dec 2015
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Slow performance with many QGraphicsItems

    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!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Slow performance with many QGraphicsItems

    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,
    _

  3. #3
    Join Date
    Dec 2015
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Slow performance with many QGraphicsItems

    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.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Slow performance with many QGraphicsItems

    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.

  5. #5
    Join Date
    Dec 2015
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Slow performance with many QGraphicsItems

    Quote Originally Posted by d_stranz View Post
    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.

    Quote Originally Posted by d_stranz View Post
    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.

  6. The following user says thank you to abbb for this useful post:

    d_stranz (24th December 2015)

  7. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Slow performance with many QGraphicsItems

    I disagree with that.
    And so do I, now that I've done some googling... 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.

Similar Threads

  1. Phonon performance slow down
    By rspock in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 10th June 2013, 08:47
  2. QT App performance is too slow on OSX
    By joshhhab in forum Newbie
    Replies: 1
    Last Post: 28th May 2011, 09:30
  3. Slow performance of QGraphicsView - why?
    By zeldaknight in forum Newbie
    Replies: 2
    Last Post: 25th August 2010, 04:34
  4. Replies: 1
    Last Post: 8th August 2010, 21:04
  5. Performance problems with overlapping qgraphicsitems
    By brjames in forum Qt Programming
    Replies: 13
    Last Post: 4th May 2008, 22:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.