#include <sys/time.h>
void ctimeTest()
{
int i=1000;
timeval tvs,tve,tvlast;
gettimeofday(&tvs,NULL);
while (--i)
{
system("cd");
}
gettimeofday(&tve,NULL);
long span = (tve.tv_sec-tvs.tv_sec) * 1000000 + (tve.tv_usec-tvs.tv_usec);
char temp[1024];
sprintf(temp,"use time: %d microsecond (1s = 1000000microsecond)",span);
printf(temp);
}
更多时间函数请参考:
http://www.ej38.com/showinfo/linux-203376.html
http://blog.csdn.net/onezeros/article/details/4559891