QueryPerformanceCounter() Test for Windows Embedded Compact 7

岁酱吖の 提交于 2019-12-08 13:11:35

问题


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?


回答1:


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];
}


来源:https://stackoverflow.com/questions/19896761/queryperformancecounter-test-for-windows-embedded-compact-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!