Is the HPET directly accessible in Windows?

2020-08-13 06:16发布

问题:

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.

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?

回答1:

I found this info while 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)



回答2:

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).

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).