转载请注明出处(不过这个用法网上到处都是):
http://www.cnblogs.com/darkknightzh/p/4987738.html
1 LARGE_INTEGER nFreq, nBeginTime, nEndTime; // 头文件为#include <windows.h> 2 QueryPerformanceFrequency(&nFreq); 3 QueryPerformanceCounter(&nBeginTime); 4 5 // code 6 7 QueryPerformanceCounter(&nEndTime); 8 double time = (double)(nEndTime.QuadPart - nBeginTime.QuadPart) * 1000 / (double)nFreq.QuadPart;
上述代码得到的是ms,如果需要得到s,不用 * 1000 即可。