目录
示例
#include "stdio.h"
#include<sys/time.h>
struct timeval T_Begin, T_End;
int main(void)
{
gettimeofday(&T_Begin, NULL);//起始时间
printf("hello\n");printf("hello\n");printf("hello\n");printf("hello\n");printf("hello\n");printf("hello\n");//耗时过程
gettimeofday(&T_End, NULL);//结束时间
double T_ms = 1000.0f * (T_End.tv_sec - T_Begin.tv_sec) + ((T_End.tv_usec - T_Begin.tv_usec) / 1000.0);//计算所耗毫秒数
printf("T_ms=%f\n",T_ms);
return 0;
}