Chinaunix首页 | 论坛 | 博客
  • 博客访问: 541458
  • 博文数量: 104
  • 博客积分: 4131
  • 博客等级: 上校
  • 技术积分: 1137
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-31 15:05
文章分类

全部博文(104)

文章存档

2011年(13)

2010年(23)

2009年(68)

我的朋友

分类: WINDOWS

2009-08-26 16:39:52

由于要测试程序运行的时间,了解算法或是硬件之类的性能,计时函数的使用非常方便。
以下是自己所写的windows测试程序:
#include
#include
void main()
{
 clock_t start ,end ,total=0;
 double a;
 int i=0;
 start=clock();
 for(i=0;i<1000000000;i++);
  //printf("%d ",i);
 end=clock();
 total=end-start;
 printf("%ld ",total);
 a=(double)total/(double)CLOCKS_PER_SEC;
 printf("\nprocess time is %lf s\n",a);
}
程序运行测试时间为4.109000s。
阅读(764) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~