您的位置:首页 > 运维架构 > Linux

Test running time in Linux

2014-03-11 08:41 337 查看
/*This program is for testing the running time of for cycle.*/

#include<sys/time.h>
#include<stdio.h>
#include<stdlib.h>

int main()
{
int i;
long int time;
struct timeval time_start;
struct timeval time_end;

gettimeofday((struct timeval*)&time_start,NULL);
for(i=0;i<10000;i++);
gettimeofday((struct timeval*)&time_end,NULL);
time=time_end.tv_usec-time_start.tv_usec;
printf("The running time of cycle is %d us",time);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: