Linux中的GetTickCount函数
#include<time.h>
unsigned long GetTickCount()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC,&tc);
return(ts.tv_sec*1000+ts.tv_nsec/1000000);
}
Linux中的Gettimeofday函数
#include<sys/time.h>
int gettimeofday(struct timeval *tv,struct timezone *tz);
struct timeval{
long tv_sec;
long tv_usec;
};
struct timeval tpstart,tpend;
float timeuse;
gettimeofday(&tpstart,NULL);
gettimeofday(&tpend,NULL);
timeuse=1000000*(tpend.tv_sec-tpstart.tv_usec)+tpend.tv_usec-tpstart.tv_usec;
printf("Used Time:%f\n",timeuse);