Results 1 to 5 of 5

Thread: high processor waste...

  1. #1
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default high processor waste...

    Here's the code: http://www.file-upload.net/download-...atrix.zip.html
    The Problem is the high processor waste. I think i implemented the QThread wrong. Thanks for help!

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: high processor waste...

    You're scheduling way too much paint events... every 100ms and every 20ms => 60 paint events/second.
    and using the threads matrix streams that way is not really safe.
    the paint event is asynvhronous and you read there the streams from the worker... but the in the same time the thread could update the streams.

    also, what is the point of that mutex in the two update methods? I don't really see its use.

    one last thing: you're creating the matrix streams in the thread's constructor, therefore they will live in the main thread. I don't think that causes any damage in your case...

  3. #3
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: high processor waste...

    ok.. so the problem is the painting. i think i have to use opengl? or can i speed up the Qt paint engine?

  4. #4
    Join Date
    Jan 2006
    Location
    Boston, MA
    Posts
    40
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: high processor waste...

    Just wanna mention - you can use profiler to find possible bottlenecks. Or in your case prove its really painting.
    http://wiki.qtcentre.org/index.php?t...with_GNU_gprof

  5. #5
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: high processor waste...

    Yes, it's probably the renderering that's your bottleneck. OpenGL would be faster if you want to keep the frame rate, but you should cache the font as display lists instead of rendering every single letter(caching the font is probably a good idea even if you decide against opengl). Also, your usage of threads doesn't seem justified since you are controlling the animation with timers anyway.

Similar Threads

  1. high resolution timer
    By ChasW in forum Qt Programming
    Replies: 18
    Last Post: 24th June 2011, 19:50

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.