使用QueryPerformanceFrequency 计算程序执行时间
2012-07-30 13:11
429 查看
QueryPerformanceFrequency( __out LARGE_INTEGER *lpFrequency ); //返回定时器的频率
BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount); //是返回定时器当前计数值
代码:
BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount); //是返回定时器当前计数值
代码:
///////////////////////////////////////////////// #include <iostream> #include <windows.h> using namespace std; //////////////////////////////////////////////// void main() { _LARGE_INTEGER time_start; /*开始时间*/ _LARGE_INTEGER time_over; /*结束时间*/ double dqFreq; /*计时器频率*/ LARGE_INTEGER f; /*计时器频率*/ QueryPerformanceFrequency(&f); dqFreq=(double)f.QuadPart; QueryPerformanceCounter(&time_start); Sleep(1000);/*循环耗时*/ QueryPerformanceCounter(&time_over); cout<<((time_over.QuadPart-time_start.QuadPart)/dqFreq)<<endl;//单位为秒,精度为1000 000/(cpu主频)微秒 }
相关文章推荐
- 使用QueryPerformanceFrequency 计算程序执行时间
- 使用QueryPerformanceFrequency 计算程序执行时间
- 使用QueryPerformanceFrequency 计算程序执行时间
- 使用QueryPerformanceFrequency 计算程序执行时间
- QueryPerformanceFrequency() 计算程序运行时间
- php使用microtime(true)计算php程序代码执行消耗时间
- php使用microtime(true)计算php程序代码执行消耗时间
- 使用QueryPerformance* api计算时间
- CCS中使用DSP定时器的计时程序,可以精确计算某一段程序的执行时间
- Windows环境是使用C语言计算程序或算法执行时间的不同粒度实现
- 使用QueryPerformance* api计算时间
- php使用microtime(true)计算php程序代码执行消耗时间
- QueryPerformanceCounter精确计算执行时间
- 精确计算代码执行的时间差(毫秒)-QueryPerformanceFrequency。
- 如何精确计算程序运行时间——精确获取时间(QueryPerformanceCounter)
- 计算两个时间的时间差 就是 计算执行一段程序使用的时间
- 计算程序运行时间的函数Sleep,clock,GetTickCount,QueryPerformanceCounter
- 计算程序执行时间的脚本python3.6(Win7x64)
- QueryPerformanceCounter 程序运行时间的开销探讨
- QueryPerformanceCounter & QueryPerformanceFrequency精确获得系统时间