您的位置:首页 > 其它

记录程序运行时间的程序实例

2014-11-10 13:33 197 查看
记录一个程序所用时间,另外在linux服务器上提交东西的指令

yhrun -p TH_NEW ./a.out >

1 #include <cstdio>
2 #include <ctime>
3 #include <cstdlib>
4 #include <sys/time.h>
5 #include <time.h>
6 struct node {
7     int   a[3];
8 };
9 node ans [16][3920][18000];
10 int main()
11 {
12     printf("start!\n");
13     int a;
14     srand(0);
15     struct timeval tv_start,tv_end;
16     gettimeofday(&tv_start,NULL);
17 //程序
27     gettimeofday(&tv_end,NULL);
28     printf("time: %lf\n",tv_end.tv_sec - tv_start.tv_sec+(tv_end.tv_usec - tv_start.tv_    usec)/1000000.0);
29     return 0;
30 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: