Results 1 to 9 of 9

Thread: How reliable are QTimers on Windows?

Hybrid View

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

    Default Re: How reliable are QTimers on Windows?

    Quote Originally Posted by stevey View Post
    I believe the smallest time you can respond to anyway on most OS's is 50ms. Anyone disagree with this?
    You can absolutely except better precision than that. As someone suggested I would set up a separate thread which polls the time and sleeps. Do a google search for "high performance timer".
    http://frank.mtsu.edu/~csjudy/direct...anceTimer.html

  2. #2
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    101
    Thanked 15 Times in 15 Posts

    Default Re: How reliable are QTimers on Windows?

    Regarding the suggestion of using a seperate thread, why should I do that? Is a sleep based control more precise, than a timer based control? My guts say that it isn't, because you never now when a thread will be woken up again and it might have slept too long.

    I think the trade off between having a faster timer and the complication plus windows dependency of the code is not worth it for me. I can live with 16 ms as long as the rhythm is steady. The most important criterion is that every iteration should take an equal amount of time.

    So the question that hasn't been addressed yet is, how precise are the timings that I get from QTime? When it says 16 ms, has it really been 16 ms? Or something between 10 and 20?

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

    Default Re: How reliable are QTimers on Windows?

    Quote Originally Posted by Cruz View Post
    So the question that hasn't been addressed yet is, how precise are the timings that I get from QTime? When it says 16 ms, has it really been 16 ms? Or something between 10 and 20?
    On XP+ between 10 and 20 ms. on NT between 0 and 50 ms, assuming the GUI thread isn't too busy.

  4. #4
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    101
    Thanked 15 Times in 15 Posts

    Default Re: How reliable are QTimers on Windows?

    Hm, here it says that QTimer now uses the multimedia timer API on Win XP and it should have a 1 ms resolution. That sounds good actually. But then how come that my measurements in my OP report 16 ms instead of 12? Could it be that the gui thread takes that long to process events before it can fire the timer? Or is it because the answer from Qtime::restart() is not precise?

  5. #5
    Join Date
    Jan 2006
    Posts
    132
    Qt products
    Qt4
    Platforms
    Windows
    Thanked 16 Times in 16 Posts

    Default Re: How reliable are QTimers on Windows?

    You should try to understand the difference between windows and a real time operation system, for example QNX. No matter how hard you try, an application will NEVER be able to answer or process any request exactly per millisecond:

    Besides your application, many other applications and system processes are running at same time sharing all the same processor and memory, and the scheduler will assign time to them in a non-tranparent way (non-transparent for the application). There is absolutely no guarantee that your application will get any processing time at all between two of your ticks. This is something beyond the scope of Qt (or any other application framework).

Similar Threads

  1. Qt Jambi, deploying app on Mac & Windows fails
    By ChrisColon in forum Installation and Deployment
    Replies: 2
    Last Post: 16th February 2009, 23:05
  2. Replies: 5
    Last Post: 15th January 2009, 10:03
  3. Opening text file fails after autostartup on windows
    By yogourta in forum Qt Programming
    Replies: 2
    Last Post: 18th October 2008, 04:52
  4. converting unix exe to windows binary
    By deekayt in forum General Programming
    Replies: 2
    Last Post: 17th September 2006, 02:00
  5. Qt and windows vista
    By munna in forum General Discussion
    Replies: 8
    Last Post: 11th January 2006, 23:33

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
  •  
Qt is a trademark of The Qt Company.