/*************************************************************
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;
}