hpet

HPET's frequency vs CPU frequency for measuring time

拟墨画扇 提交于 2019-11-29 12:31:19
I need to measure function execution time in nanoseconds. Now I want to understand if my computer can do that and what is the precision of measurement. There was a suggestion to use QueryPerformanceFrequency() to obtain the HPET's frequency and 1/hpetFrequency is the atomic time that can be measured. Is this right? I mean if my cpu frequency is 3.33 GH, even 1GHz that one clock duration is one nanoseconds. Doesn't it mean that I can measure by nanoseconds? For measuring time CPU or HPET's frequency is essential and why? You cannot measure to 1 nanosecond, you cannot measure to 10 nanosconds