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

QTimer consumes too much CPU

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Invalid
    • Affects Version/s: 4.5.2
    • Fix Version/s: None
    • Component/s: Core: Event loop
    • Labels:
      None
    • Environment:
      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

        For Gerrit Dashboard: QTBUG-7618
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            bhughes Bradley T. Hughes (closed Nokia Identity) (Inactive)
            Reporter:
            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