用QueryPerformanceFrequency 和 QueryPerformanceCounter 进行高精度计时
2011-03-21 11:06
423 查看
void main() {
LARGE_INTEGER lv;
// 获取每秒多少CPU Performance Tick
QueryPerformanceFrequency( &lv );
// 转换为每个Tick多少秒
double secondsPerTick = 1.0 / lv.QuadPart;
for ( size_t i = 0; i < 100; ++i ) {
// 获取CPU运行到现在的Tick数
QueryPerformanceCounter( &lv );
// 计算CPU运行到现在的时间
// 比GetTickCount和timeGetTime更加精确
double timeElapsedTotal = secondsPerTick * lv.QuadPart;
cout.precision( 6 );
cout << fixed << showpoint << timeElapsedTotal << endl;
//printf( "%lf \n", timeElapsedTotal ) ;
}
}
http://www.cppblog.com/bidepan2023/archive/2008/01/22/41627.html
LARGE_INTEGER lv;
// 获取每秒多少CPU Performance Tick
QueryPerformanceFrequency( &lv );
// 转换为每个Tick多少秒
double secondsPerTick = 1.0 / lv.QuadPart;
for ( size_t i = 0; i < 100; ++i ) {
// 获取CPU运行到现在的Tick数
QueryPerformanceCounter( &lv );
// 计算CPU运行到现在的时间
// 比GetTickCount和timeGetTime更加精确
double timeElapsedTotal = secondsPerTick * lv.QuadPart;
cout.precision( 6 );
cout << fixed << showpoint << timeElapsedTotal << endl;
//printf( "%lf \n", timeElapsedTotal ) ;
}
}
http://www.cppblog.com/bidepan2023/archive/2008/01/22/41627.html
相关文章推荐
- 用 QueryPerformanceFrequency 和 QueryPerformanceCounter 进行高精度计时
- 用 QueryPerformanceFrequency 和 QueryPerformanceCounter 进行高精度计时
- 高精度计时QueryPerformanceCounter/QueryPerformanceFrequency
- cocos2d-x 精确计时使用: QueryPerformanceCounter 与QueryPerformanceFrequency
- QueryPerformanceFrequency高精度计时
- //Windows系统下可以用 time(),clock(),timeGetTime(),GetTickCount(),QueryPerformanceCounter()来对一段程序代码进行计时
- 使用QueryPerformanceFrequency、QueryPerformanceCounter精确计时
- 高精度计时函数QueryPerformanceCounter
- QueryPerformanceFrequency高精度计时
- 精确时间计时QueryPerformanceCounter,QueryPerformanceFrequency
- 高精度计时器---QueryPerformanceFrequency()与QueryPerformanceCounter()的使用
- 使用QueryPerformanceFrequency、QueryPerformanceCounter精确计时
- GetTickCount/QueryPerformanceFrequency/QueryPerformanceCounter
- QueryPerformanceFrequency 和 QueryPerformanceCounter用法
- QueryPerformanceFrequency()和QueryPerformanceCounter()
- QueryPerformanceCounter,QueryPerformanceFrequency
- 【C++】高精度代码运行时间( QueryPerformanceCounter )
- QueryPerformanceCounter & QueryPerformanceFrequency精确获得系统时间
- 高精度计时器QueryPerformanceCounter正确的打开方式(windows环境下)
- QueryPerformanceFrequency高精度定时