What is the best, most accurate timer in C++?

前端 未结 4 1992
暗喜
暗喜 2020-12-06 11:50

What is the best, most accurate timer in C++?

4条回答
  •  -上瘾入骨i
    2020-12-06 12:52

    The answer to this is platform-specific. The operating system is responsible for keeping track of timing and consequently, the C++ language itself provides no language constructs or built-in functions for doing this.

    However, here are some resources for platform-dependent timers:

    • Windows API - SetTimer: http://msdn.microsoft.com/en-us/library/ms644906(v=vs.85).aspx
    • Unix - setitimer: http://linux.die.net/man/2/setitimer

    A cross-platform solution might be boost::asio::deadline_timer.

提交回复
热议问题