Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-7618

QTimer consumes too much CPU

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 4.5.2
    • Core: Event loop
    • None
    • Linux

    Description

      QTimer spends up to the last millisecond of the timer interval busy-waiting, in its attempt to be very accurate. In an application that attempts to use QTimer to animate the screen at the display's refresh rate, e.g. 70Hz, the application may consume a significant fraction of the CPU (up to 7% in this example) just within the QTimer class, and this fraction may be the same regardless of the processor speed. This excess CPU usage is at the detriment of other running threads or processes.

      It seems that something like nanosleep() could be used instead for that last millisecond, to maintain similar accuracy but with a minimum of CPU usage.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bhughes Bradley T. Hughes (closed Nokia Identity) (Inactive)
            stichnot Jim Stichnoth
            Votes:
            6 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes