问题描述
限时送ChatGPT账号..我知道默认值是每滴答 15.6 毫秒,但有些失败者可能会更改它,然后一次又一次地来回更改,我需要轮询当前值以执行有效的 QueryPerformanceCounter 同步.
I know that the default is 15.6 ms per tick, but some loser may change it and then change back and forth again and again, and I need to poll what the current value is to perform valid QueryPerformanceCounter synchronization.
那么有没有获取定时器分辨率的 API 方法?
So is there an API way to get the timer resolution?
顺便说一句,我在使用 C++.
I'm on C++ BTW.
推荐答案
Windows 计时器解析由隐藏的 API 调用提供:
Windows timer resolution is provided by the hidden API call:
NTSTATUS NtQueryTimerResolution(OUT PULONG MinimumResolution,
OUT PULONG MaximumResolution,
OUT PULONG ActualResolution);
NtQueryTimerResolution 由本地 Windows NT 库 NTDLL.DLL 导出.
NtQueryTimerResolution is exported by the native Windows NT library NTDLL.DLL.
常见硬件平台为 ActualResolution 报告 156,250 或 100,144;较旧的平台可能会报告更大的数字;较新的系统,尤其是在支持 HPET(高精度事件计时器)或恒定/不变 TSC 时,可能会为 ActualResolution 返回 156,001.
Common hardware platforms report 156,250 or 100,144 for ActualResolution; older platforms may report even larger numbers; newer systems, particulary when HPET (High Precision Event Timer) or constant/invariant TSC are supported, may return 156,001 for ActualResolution.
对 timeBeginPeriod(n)
的调用反映在 ActualResolution 中.
Calls to timeBeginPeriod(n)
are reflected in ActualResolution.
在这个答案中有更多细节.
这篇关于如何获取当前 Windows 系统范围的计时器分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论