头文件
#include "sys/time.h"
全局/局部变量
static struct timeval st;
static struct timeval ed;
static double time_total;
函数调用
gettimeofday(&st, NULL);
gettimeofday(&ed, NULL);
time_total = (ed.tv_sec - st.tv_sec) + (ed.tv_usec - st.tv_usec) / 1000000.0;
printf("[time_total]:%lf S\n", time_total);