Windows 是否为应用程序提供单调递增的时钟

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/211257/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:28:58  来源:igfitidea点击:

Does Windows provide a monotonically increasing clock to applications

windowstimetimer

提问by gyrolf

This question is inspired by Does Linux provide a monotonically increasing clock to applications.

这个问题的灵感来自于Linux 是否为应用程序提供了一个单调递增的时钟

Maybe I should be more precise: I'm looking for a clock function which is strictly increasing, thus never returning the same value, independant how quick two calls follow each other.

也许我应该更精确:我正在寻找一个严格递增的时钟函数,因此永远不会返回相同的值,独立于两个调用相互跟随的速度。

采纳答案by Greg Hewgill

Yes, GetTickCount()does this. If you want a higher fidelity counter, QueryPerformanceCounteris also available. Neither of these counters depend on the time of day.

是的,GetTickCount()这样做。如果你想要一个更高保真度的计数器,QueryPerformanceCounter也是可用的。这些计数器都不依赖于一天中的时间。