c++ - Is QueryPerformanceFrequency accurate when using HPET? -


i'm playing around queryperformancefrequency. used return 3.6 mhz, not enough trying do.

i've enabled hpet using command bcdedit /set useplatformclock true. returns 14.3 mhz. it's great it's more precise... excepted it's not. realized did not granularity expected.

if try poll queryperformancecounter until ticks, smallest increment can 11, means 1.27mhz. if try count number of different values can queryperformancecounter in 1 second, 1.26mhz.

so wondering there way use 14.3 mhz full extent ?

i'm using windows 7, 64 bit system, visual studio 2008.

using hpet hardware source queryperformancecounter (qpc) known assosiated large overheads.

qpc expensive call when configured hpet.

it provides 14.3 mhz suggests high accuracy found, can't called fast enough resolve frequency.

therefore microsoft has turned cpus time stamp counter (tsc) source qpc whenever hardware capable doing so. tsc queries have lower overhead. associated frequency used qpc typically cpu frequency divided 1024; typically few mhz.

the call of qpc in tsc mode fast lot of consecutive calls may show same result (typically approx. 20-30 calls or 15 - 20 ns/call). way may obtain typical resolutions of approx. 0.3 (on 3.4 ghz cpu).

you observed 3.6 mhz before switched hpet. that's signiture of systems acpi pm timer (3579545 hz), indicates not operating on tsc based qpc before switching hpet.

so either way, running hpet or acpi pm timer results in usable resoluion in range of few mhz. both cannot expose full resolution given performance counter frequency (pcf) because call qpc expensive. tsc based qpc fast enough , capable oversample qpc.

microsoft has released more detailed information matter:

see acquiring high-resolution time stamps (msdn 2014) details.

this comprehensive article lots of examples , detailed description. must read users of qpc.

...a way use 14.3 mhz full extent ?

unfortunately not.

you can run coreinfo.exe utility windows sysinternals. sysinternals has moved microsoft technet. here link: sysinternals system information utilities. give answer question: how can check if system has non-invariant tsc?

summary: best resolution/accuracy/granularty obtained qpc based on tsc.

btw: proper choice of hardware resource qpc influences call expense of new getsystemtimepreciseasfiletime function (windows 8 desktop , upwards) because internally uses qpc.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -