LARGE_INTEGER m_nFreq2;LARGE_INTEGER m_nBeginTime2;LARGE_INTEGER nEndTime2;QueryPerformanceFrequency(&m_nFreq2); // 获取时钟周期QueryPerformanceCounter(&m_nBeginTime2); // 获取时钟计数// 开始计时cout << "求平均数中……";Average(number,n);QueryPerformanceCounter(&nEndTime2);cout << "求平均数结束,用时:" << (double)(nEndTime2.QuadPart - m_nBeginTime2.QuadPart) * 1000 / m_nFreq2.QuadPart << "ms" << endl;
时钟周期的头文件
#include <windows.h>