High-resolution timer



  • Hello. I have such a problem: I need to measure time precisely, acceptable inaccuracy is about 1-2 msec. I use Qt SDK 1.1 on Windows XP. I tried QTimer, clock(), chrono, I also tried to increase application priority to Real time but inaccuracy always is 5 msec (or 15, I'm not sure about it). Could anybody please tell me what's the problem and how to deal with it?


  • Qt Champions 2016

    @AntonZelenin
    Hello,
    Did you try setting the timer type? If the OS has a precise timer you should be able to get about that accuracy.

    I also tried to increase application priority to Real time

    This is irrelevant in this particular case.

    PS.

    I need to measure time precisely

    If you only need to measure the time between two points in your code, then you can use QElapsedTimer.

    Kind regards.



  • @kshegunov
    My version of Qt appears not to have timer types. And QElapsedTimer gave me only 10 msec accuracy=(


  • Qt Champions 2016

    @AntonZelenin
    Are you perchance using Qt 4, as the timer types are introduced in Qt 5?
    If that's so (which is very probable) I advise to switch to Qt 5. Qt 4 has been marked not advised for new development.

    And QElapsedTimer gave me only 10 msec accuracy

    This would ultimately depend on the accuracy the OS can provide.

    Kind regards.



  • @kshegunov
    If I switch to Qt5, I'll have to change some my code... And if I switch to Qt5, will my app still be compatible with Windows XP?


  • Qt Champions 2016

    @AntonZelenin

    If I switch to Qt5, I'll have to change big enough amount of my code...

    I sympathize, but bear in mind Qt 4 is pretty old now (even the latest version).

    And if I switch to Qt5, will my app still be compatible with Windows XP?

    I don't know, sorry. Perhaps some of our Windows users will pitch in and say if Qt 5 works fine on win XP.



  • I have a Qt application that was build with Qt 5.6 and sadly (or to my surprise) I know of nearly a dozen users that use it on Windows XP without any issues.
    Of course this might depend on the features and modules that you are using. So just to be sure: I am not saying you that your application will definitely work on Windows XP if you move to Qt 5. I'm just saying that my application(s) appear to work for Windows XP users.

    Edit: For more information you might want to check out this: https://doc.qt.io/qt-5/supported-platforms.html



  • Okay, thank you both. I'll try to use Qt5=)
    Should I mark this topic as Solved now?


  • Qt Champions 2016

    @AntonZelenin

    Okay, thank you both. I'll try to use Qt5=)

    No problem and good luck!

    Should I mark this question as Solved now?

    If you're satisfied with the answers please do.
    (Someone might add something later irrespective of the topic being marked as solved, it's only a marker of sorts)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.