在 Windows 中可以直接访问 HPET 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/786324/
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
Is the HPET directly accessible in Windows?
提问by Promit
I would like to use the High Performance Event Timer (HPET) for an profiling tool to take very high precision measurements, quickly. timeGetTime does not provide sufficient resolution at 1ms, and QueryPerformanceCounter is much slower per read than I'd like. I came across the HPET while researching the problem, but I can't see any samples of how to actually get at it.
我想使用高性能事件计时器 (HPET) 作为分析工具来快速进行非常高精度的测量。timeGetTime 在 1ms 时没有提供足够的分辨率,而且每次读取 QueryPerformanceCounter 的速度比我想要的要慢得多。我在研究问题时遇到了 HPET,但我看不到任何有关如何实际解决它的示例。
So can I use it directly (assembly is fine), or do I have to rely on the multimedia/high performance timing tools already built into the Win32 API?
那么我可以直接使用它吗(汇编很好),还是必须依赖已经内置在 Win32 API 中的多媒体/高性能计时工具?
采纳答案by leppie
I found this infowhile digging around, and it seems it can be the most cost effective way. I will try it out when I get the guts to dig into assembly. :)
我在挖掘时发现了这个信息,这似乎是最具成本效益的方式。当我有勇气深入组装时,我会尝试一下。:)
UPDATE
更新
I tested this with my profiler. although a bit faster, it seems I still have tonnes of other overhead :( (I did not bother with timing as I it did not seem to be enough benefit)
我用我的分析器测试了这个。虽然快了一点,但似乎我还有很多其他开销:((我没有在意时间,因为我似乎没有足够的好处)
回答by darda
I am also interested in using the HPET, but as a timer. The way I understand it, QueryPerformanceCounter and QueryPerformanceFrequency are actually accessing the counter and clock for the HPET, and this works under Windows XP (see, for example, http://www.geisswerks.com/ryan/FAQS/timing.html).
我也对使用 HPET 感兴趣,但用作计时器。根据我的理解,QueryPerformanceCounter 和 QueryPerformanceFrequency 实际上是访问 HPET 的计数器和时钟,这在 Windows XP 下有效(例如,参见 http://www.geisswerks.com/ryan/FAQS/timing.html) .
So as far as timing code, I think by using QueryPerformanceCounter you are in fact getting access to the counter that form the base of HPET, and this is all present in the chipset (rather than the processor).
因此,就时序代码而言,我认为通过使用 QueryPerformanceCounter,您实际上可以访问构成 HPET 基础的计数器,而这一切都存在于芯片组(而不是处理器)中。