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

记录一个程序所用时间,另外在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 }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值