今天在做一個(gè)大數(shù)據(jù)文件創(chuàng)建的時(shí)候,為了測(cè)量創(chuàng)建所用的時(shí)間,特意研究了下,windows下時(shí)間的獲取
1、55ms分辨率的計(jì)時(shí):
頭文件:#include
GetTickCount() 用法:
DWORD dwStart = GetTickCount();
functon(); // Your program.
DWORD dwEnd = GetTickCount();
DWORD dwTimes = dwEnd - dwStart;
2、10ms分辨率的計(jì)時(shí):
頭文件:
#include
#include
#pragma comment( lib,"winmm.lib" )
timeGetTime()用法:
DWORD dwStart = timeGetTime();
function; // Your program
DWORD dwEnd = timeGetTime();
DWORD dwTimes = dwEnd - dwStart;
3、1ms分辨率的計(jì)時(shí):
頭文件:
#include
clock()用法:
clock_t s_time= clock();
function();
clock_t e_time= clock();
clock_t time = e_time - s_time;