the software timer returns here correctly the 500ms, but the hardware timer returns ~1457359560 here. whats that value?! this cant be millisecs, shouldnt QueryPerformanceCounter() return millisecs or have i missed something??
The high resolution PerformanceCounter gives you "counts per second" which with todays CPUs is several million counts per second. QueryPerformanceFrequency_() returns the number of "counts per second" the hardware you are running on is capable of.
Together with QueryPerformanceCounter_() you have a timer resolution that on the fastest CPUs will be in the nanoseconds range. Very nice for benchmarking single instructions
QueryPerformanceFrequency returns the maximum number of slices you can cut one second into. It's usually a very high number, around four million on my machine. To get an accurate timeslice equal to one millisecond, you divide that number by 1000 and that is what you will test using QueryPerformanceCounter to see if a millisecond has gone by yet.
Here's a procedure that accurately returns ticks at a resolution of one ms: (by rescator)
Theoretically, yes. But from a practical standpoint, at res's of up to 1/10 ms the function overhead is not significant enough to impact accuracy. Res's much higher than that are not practical for much, afaik. You can't get FPS anywhere near that, for example. My testing shows no degradation of accuracy that would impact a practical application of the counter. But - you're more than welcome to improve on it!
Last edited by netmaestro on Tue Apr 04, 2006 9:47 am, edited 1 time in total.
thanks guys for clearing this up and thanks netmaestro for the example code, this will become pretty handy. now i have a better idea of how to use this great highres counter.
Of course at that res theres no problem, I just pointed out that there is an overhead .. For benchmarking purposes it would be cool if you took the overhead into account and reduced it from the result value.
I just like to see things well done even if sometimes theres not a big difference
! Black holes are where God divided by zero ! My little blog! (Not for the faint hearted!)