今天在做一個大數據文件創建的時候,為了測量創建所用的時間,特意研究了下,windows下時間的獲取
1、55ms分辨率的計時:
頭文件:#include
GetTickCount() 用法:
DWORD dwStart = GetTickCount();
functon(); // Your program.
DWORD dwEnd = GetTickCount();
DWORD dwTimes = dwEnd - dwStart;
2、10ms分辨率的計時:
頭文件:
#include
#include
#pragma comment( lib,"winmm.lib" )
timeGetTime()用法:
DWORD dwStart = timeGetTime();
function; // Your program
DWORD dwEnd = timeGetTime();
DWORD dwTimes = dwEnd - dwStart;
3、1ms分辨率的計時:
頭文件:
#include
clock()用法:
clock_t s_time= clock();
function();
clock_t e_time= clock();
clock_t time = e_time - s_time;
這裡有跟全的資料:http://blog.csdn.net/cometdlut/article/details/5839348