Windows Embedded Compact 7 的 QueryPerformanceCounter() 测试 [英] QueryPerformanceCounter() Test for Windows Embedded Compact 7

查看:27
本文介绍了Windows Embedded Compact 7 的 QueryPerformanceCounter() 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

循环 QueryPerformanceCounter() 并保存值:

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

(除以 PCFreq 给出每次调用之间的时间.)

(Divide by PCFreq gives time between each call.)

高分辨率计时器/计数器应该可以工作,因为它没有返回默认频率 1000.

The high resolution timer/counter is supposedly working because it is not returning the default frequency 1000.

每个时间戳之间的平均值为 11.990884 微秒(一千个时间戳调用).

Average of 11.990884 microseconds between each time stamp (a thousand time stamp calls).

这似乎非常慢.

这个测试有缺陷吗?

或者关于为什么它在 1.1Ghz Celeron 上报告如此缓慢的值的想法?

or ideas as to why its reporting such slow values on a 1.1Ghz Celeron?

推荐答案

为了避免 Win 7 Desktop 和 Embedded Compact 7 之间的(潜在)差异,消除第一个循环中的浮点数学可能是值得的考虑.所以,就像:

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

这篇关于Windows Embedded Compact 7 的 QueryPerformanceCounter() 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆