全部评论(4条)
-
- wszaizhj 2010-12-04 00:00:00
- #include <stdio.h> #include <stdlib.h> #include <time.h> void sleep( clock_t wait ); void main( void ) { long i = 600000L; clock_t start, finish; double duration; /* Delay for a specified time. */ printf( "Delay for three seconds\n" ); sleep( (clock_t)3 * CLOCKS_PER_SEC ); printf( "Done!\n" ); /* Measure the duration of an event. */ printf( "Time to do %ld empty loops is ", i ); start = clock(); while( i-- ) ; finish = clock(); duration = (double)(finish - start) / CLOCKS_PER_SEC; printf( "%2.1f seconds\n", duration ); } /* Pauses for a specified number of milliseconds. */ void sleep( clock_t wait ) { clock_t goal; goal = wait + clock(); while( goal > clock() ) ; } If you have another problems,you may call me.
-
赞(6)
回复(0)
-
- 酒醉伊人__e 2016-01-09 00:00:00
- 获取机器时钟。
-
赞(8)
回复(0)
-
- 冰旭冰旭冰 2010-12-04 00:00:00
- #include <windows.h> #include <stdio.h> #include <time.h> typedef long ClockT; ClockT start; ClockT finish; double dtime; int main () { //开始计时保存到start start=clock(); //具体运算 Sleep(1900); //结束计时保存到finish finish=clock(); dtime=(double)(finish-start); printf("精确时间: %lf\n",dtime); printf("一般时间: %lf\n",dtime/CLOCKS_PER_SEC); return 0; }
-
赞(17)
回复(0)
-
- eryrejk 2017-10-07 22:57:45
- #include <ctime> #include <iostream> using namespace std; int main () { clock_t start, finish; //typedef long clock_t; double totaltime; start = clock(); //clock():Current time of CPU for (int i = 0; i < 1000000; i++) { } finish=clock(); totaltime=(double)(finish-start)/CLOCKS_PER_SEC; cout<<"\nRuntime is: " << totaltime << "s" << endl; return 0; } 中间位置是你需要测试的函数,为简便我只写了一个for循环~
-
赞(5)
回复(0)
热门问答
- 如何在C++程序中添加计时器判断两个函数的运行时间长短
2010-12-03 02:27:11
312
4
- 计时器c++程序
2017-11-28 03:11:16
207
1
- 如何在PVC中添加交联剂
2018-11-10 14:34:17
359
0
- 如何在matlab中添加工具包
2016-04-07 18:47:27
343
1
- 如何在PowerPoint中插入计时器
2016-04-08 04:58:15
259
3
- 如何在程序中提高传感器的反应速度
2018-07-30 22:18:13
340
1
- 如何在GX PLC编程软件中添加注释?
2010-05-26 19:14:10
306
2
- 如何在PPT(powerpoint)中增加计时器效果?
- 如题。 因为PPT需要。希望在PPT播放时能有一个显示的效果。 因为必须在30分钟内结束PPT播放,所以要让观众看到时间流逝的效果。 每一页都需要这么个显示功能。 我用的是PPT 2003的简化版本。
2008-05-27 18:24:57
303
3
- 如何在VB程序中设计一个器
2018-12-06 17:40:52
222
0
- .net 如何在服务器端做一个计时器
- 我要在服务器算写一个计时器、每隔12小时去检索一下 数据库的内容 access 数据库 呵呵、有没有高手帮忙呀、 Z好把代码贴出来!
2010-09-05 02:41:22
416
3
- 如何在ppt 2010中加入计时器
2017-06-14 12:59:32
277
1
- 如何在Ubuntu下添加中文字符集支持(解决中
2018-06-17 10:01:58
338
1
- 如何用系统函数判断高通滤波器
2017-11-21 21:21:32
769
1
- 如何用VB程序做计时器?
2017-11-23 14:26:59
430
1
- c++程序运行时出现abnormal program termination编译没有错代码如下
- #include
#include #include #include using namespace std; int main() { string M; string P; string FCS; string MTemp; ifstream MFile("F:\\学习事宜\\大二\\计算机网络\\CRC\\input_M.txt"); if... #include #include #include #include using namespace std; int main() { string M; string P; string FCS; string MTemp; ifstream MFile("F:\\学习事宜\\大二\\计算机网络\\CRC\\input_M.txt"); ifstream PFile("F:\\学习事宜\\大二\\计算机网络\\CRC\\input_P.txt"); ofstream FCSFile("F:\\学习事宜\\大二\\计算机网络\\CRC\\output_FCS.txt"); getline(MFile, M); getline(PFile, P); MTemp=M; MTemp.append(P.length()-1,'0'); for(unsigned int i=0; i<=MTemp.length()-P.length();i++) { if(MTemp[i]=='0') continue; string MSubTemp=MTemp.substr(i, P.length()); for(unsigned int j=0;j 2015-06-16 19:13:28 300 1
- 如何在win32里面设置一个计时器?
2013-05-26 05:00:18
284
2
- 电动机运行时为什么添加油脂
2011-10-12 00:44:15
448
5
- 如何在pxi上编写labview程序
- 很多PC上可用的labview的命令在pxi上都不可以用,哪里有比较详细介绍pxi上编程的资料?谢谢!
2018-11-15 00:32:55
275
0
- 如何在饲料中控制抗生素的添加量
2017-02-17 15:32:59
318
1
- 如何用QT实现一个计时器的程序
- 秒表,用户点“开始计时”后,秒表开始计时,并实时显示计时数据;用户点“停止计时”后,秒表停止计时;用户点“重置”后,秒表归零 要求:秒表计时精度达到毫秒级 说明:不要求存储历史计时数据 需要详细点
2015-07-22 03:12:45
377
1
10月突出贡献榜
推荐主页
最新话题
参与评论
登录后参与评论