现在的位置: 首页 > 综合 > 正文

获取程序执行时间

2013年02月02日 ⁄ 综合 ⁄ 共 450字 ⁄ 字号 评论关闭

/*calculate time*/
#include "time.h"
#include "stdio.h"
#include "conio.h"
main()
{
  time_t start,end;
  int i;
  start=time(NULL);
  /*这里是程序其他代码*/
  end=time(NULL);
  printf("/1: The different is %6.3f/n",difftime(end,start));
  getch();
}

=============================================

#include "time.h"
int main( void )
{
   clock_t start, finish;
   double  usetime;
   start = clock();
   //这里写你测试程序
   finish = clock();
   usetime= (double)(finish - start) / CLOCKS_PER_SEC;
   printf( "程序用时%f 秒/n", usetime);
}
 

抱歉!评论已关闭.