Linux 下C语言测量程序运行的时间
添加头文件
#include <sys/time.h>
测量方法
struct timeval StartTime; struct timeval EndTime; double TimeUse=0; gettimeofday(&StartTime, NULL); //测量开始 //要测量的程序代码 gettimeofday(&EndTime, NULL); //测量结束 TimeUse = 1000000*(EndTime.tv_sec-StartTime.tv_sec)+EndTime.tv_usec-StartTime.tv_usec; TimeUse/=1000; //测量结果,毫秒级别
本文来自博客园,作者:白菜没我白,转载请注明原文链接:https://www.cnblogs.com/xingboy/p/14517760.html

浙公网安备 33010602011771号