如何实现程序的计时
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;
#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;
相关文章推荐
- 如何实现程序的精确计时
- Android_如何在程序中实现apk的安装
- 如何在Linux实现自动运行程序
- 如何通过程序实现同一事务中多次数据库更新的错误回滚?
- 如何用Shell实现程序组快捷方式的添加
- 如何用程序实现增加二级windows文件右键菜单
- Linux如何实现开机启动程序详解
- 有一个二叉树, 节点全部为整数,如何找到一个子树,它所有节点的和最大?要求编程序实现。
- 如何用小程序功能实现流量变现
- 如何实现程序只有一个实例
- 手把手教你如何实现Binder的客户端程序(图文)
- 用UDP实现可靠文件传输,如何利用UDX创建一个简单的WIN32程序
- windows程序如何实现精准定时
- 中国象棋程序的设计与实现(八)-如何构造一个棋子(車馬炮等)
- 如何实现在程序中进行网络计算机的用户验证
- 如何实现最简单的Struts程序
- 如何实现android程序的多屏适配
- C#下如何实现服务器+客户端的聊天程序
- C#WinForm 如何实现屏蔽窗口右上角的关闭操作,点击时不关闭程序
- 看看node.js chat程序如何实现Ajax long-polling长链接刷新模式