#include <sys/time.h>
struct timeval start;
struct timeval end;
float time_use = 0;
gettimeofday(&start, NULL);
{计算的程序}
gettimeofday(&end, NULL);
time_use = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec); //微秒
printf("\n time_use is %.10f\n", time_use);