Results 1 to 8 of 8

Thread: refresh screen use more CPU

  1. #1
    Join Date
    Mar 2011
    Posts
    42
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default refresh screen use more CPU

    my program running in samsung s3c2440 processor, when i not refresh the paint pixmap, the program use CPU 1%-2%, but when use repaint() refresh the paint pixmap, the program use CPU 80%-90%(i invoke repaint() very fast, about 10 millisecond space), have any one have high efficiency ways to refresh the paint pixmap, thanks.

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: refresh screen use more CPU

    Just write better code.
    If you want better answer then post better question.

  3. #3
    Join Date
    Mar 2011
    Posts
    42
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: refresh screen use more CPU

    yea, thank you

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: refresh screen use more CPU

    You seem surprised that when you do no work the CPU is not busy, and when you do (a lot) of work the CPU is busy.

    Run your code in a profiler to find out where the CPU really is spending its time and focus on improving that. Odds are you will need to code that only draws bits of the pixmap that change or, more obviously, do not refresh as frequently. I am not sure what application really needs to redraw at 100Hz frequency anyway.

  5. #5
    Join Date
    Mar 2011
    Posts
    42
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: refresh screen use more CPU

    yea, i test my program it, find when i repaint pixmap, use CPU more. my program need to draw wave, so if have data to draw, i first use Qpainter draw on the QPixmap, and then use repaint() invoke paintEvent() show the pixmap, i do not know whether or not have more good methods to show the pixmap.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: refresh screen use more CPU

    How did you test your program? And why are you calling repaint() instead of update()?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Mar 2011
    Posts
    42
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: refresh screen use more CPU

    i comment repaint code, and why me calling repaint() instead of update(), because if invoke repaint(), it will immediate execute, but if invoke update(), it will wait a while, so i think if use update() may affect show wave.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: refresh screen use more CPU

    Hmm.... but if your screen refreshes at 60Hz rate and you're calling repaint() at 100Hz then you're not seeing half of the repaints so your app does twice as much as it can without losing any functionality. The fact that you call repaint() instead of update() doesn't mean the changes will be shown on the screen faster. It just means your application will be more busy doing empty repaints. Paint events can be merged to reduce the work but with repaint() you are not allowing a merge so your app has more to do. Consider this:
    Qt Code:
    1. {
    2. repaint();
    3. repaint();
    4. }
    To copy to clipboard, switch view to plain text mode 
    and this:
    Qt Code:
    1. {
    2. update();
    3. update();
    4. }
    To copy to clipboard, switch view to plain text mode 
    The first code will invoke the painting routine twice (or even more actually because the parent widget may also change and enforce an update of its child), the second will invoke it once. In both cases you will see the same result (when the display refreshes) only that the first code will execute n times longer than the second one.

    I'm not even commenting the fact that your eye cannot detect changes at 100Hz rate, you can safely drop down the frame rate to about 30 per second.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 14th January 2011, 15:09
  2. Replies: 2
    Last Post: 11th June 2010, 07:23
  3. Qt Creator Screen refresh on 64-bit Fedora 12
    By pitonyak in forum Qt Tools
    Replies: 0
    Last Post: 22nd February 2010, 19:34
  4. Replies: 4
    Last Post: 11th December 2008, 17:35
  5. Screen refresh during heavy computation
    By martinb0820 in forum Qt Programming
    Replies: 5
    Last Post: 17th November 2008, 22:20

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.