WinAPI Sleep() function call sleeps for longer than expected

后端 未结 7 629
清歌不尽
清歌不尽 2020-11-27 07:57

OS: Windows 7

When calling the WinAPI Sleep() function as Sleep(1) the thread actually sleeps for 15ms. I did it 100 times in a loop and the total sleep time was 150

7条回答
  •  一个人的身影
    2020-11-27 07:59

    (debug or release build ?)

    How are you measuring the delay ? are you using a precise method ? (queryperformancecounter)

    I don't think you should rely on the Windows OS for accurate timing; it is not a real-time operating system, and there will be external "forces" that will steal time from your process.

提交回复
热议问题