Reputation: 384
Loop through QueryPerformanceCounter() and save the value:
// Main loop for timer test
for ( int i = 0; i < ITERATIONS; i++ ) // ITERATIONS = 1000
{
QueryPerformanceCounter(&li);
time[i] = double(li.QuadPart) / PCFreq; //1,193,182 per second
}
//calculate the difference between each call
// and save in difference[]
for ( int j = 0; j < (ITERATIONS - 1) ; j++ )
{
difference[j] = time[j+1] - time[j];
}
(Divide by PCFreq gives time between each call.)
The high resolution timer/counter is supposedly working because it is not returning the default frequency 1000.
Average of 11.990884 microseconds between each time stamp (a thousand time stamp calls).
This seems extremely slow.
Is this test flawed?
or ideas as to why its reporting such slow values on a 1.1Ghz Celeron?
Upvotes: 0
Views: 526
Reputation: 231
It may be worthwhile to eliminate the floating point math in the first loop in order to keep that (potential) difference between Win 7 Desktop and Embedded Compact 7 out of consideration. So, something like:
LARGE_INTEGER counter[ITERATIONS];
// Main loop for timer test
for ( int i = 0; i < ITERATIONS; i++ ) // ITERATIONS = 1000
{
QueryPerformanceCounter(&counter[i]);
}
time[0] = double(counter[0].QuadPart) / PCFreq; //1,193,182 per second
//calculate the difference between each call
// and save in difference[]
for ( int j = 0; j < (ITERATIONS - 1) ; j++ )
{
time[j+1] = double(counter[j+1].QuadPart) / PCFreq; //1,193,182 per second
difference[j] = time[j+1] - time[j];
}
Upvotes: 2