/*************************************************************
FileName : testtime.c
FileFunc : 測試程序運行時間模板
Version : V0.1
Author : Sunrier
Date : 2012-05-25
Descp : Linux下測試程序運行時間
*************************************************************/
#include <sys/time.h>
int TestTime( void )
{
long int lTime;//默認微秒數
struct timeval start,end;
gettimeofday(&start,NULL);
function();//執行所有的函數調用
gettimeofday(&end,NULL);
lTime = 1000000*( end.tv_sec-start.sec) + end.tv_usec - start.tv_usec; //默認微秒爲單位
//如果想得到秒爲單位則lTime /= 1000000;
}