您的位置:首页 > 其它

如何实现程序的计时

2011-11-14 08:55 309 查看
最简单的

#include   <time.h>

#include   <stdio.h>

#include   <dos.h>

int   main(void)

{

        time_t   first,   second;

        first   =   time(   NULL   );

        delay(   2000   );

        second   =   time(   NULL   );

        printf( "The   difference   is:   %f   seconds\n ",difftime(second,first));

        return   0;

}秒

#include   <time.h>

  void       f()     {

        time_t   start,end,time;

start=clock();

//程序开始

//程序结束

end=clock();

time=end-start;//这里的时间是计算机内部时间

} 微秒

#include   <time.h>

//   At   the   beginning   of   your   algorithm...

clock_t   t1   =   clock();

...

//   At   the   end   of   your   algorithm...

clock_t   t2   =   clock();

float   seconds   =   (float)(t2-t1)/CLOCKS_PER_SEC;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  float null delay