clock time times
来源:互联网 发布:神仙劫宠物进阶数据 编辑:程序博客网 时间:2024/05/16 06:30
1. clock,windows下的time一样, 也和 linux下的times一样
2. clock返回clock_t型,其实就是长整型
3. clock和times返回的单位是滴答
4. 滴答根据不同的系统,和不同的标准而不同
The clock() function returns the processor time since the program started, or -1 if that information is unavailable. To convert the return value to seconds, divide it by CLOCKS_PER_SEC.(windows)
times 和 clock都收用来计算cpu时间。times函数的返回值是进程迄今为止的存活时间。所有时间都是以“滴答”为单位的,linux系统下,函数 sysconf(_SC_CLK_TCK)可获得所运行系统每秒的滴答数。
typedef long clock_t;
- //windows
- #include <stdio.h>
- #include <time.h>
- int main()
- {
- printf("%ld\n", CLOCKS_PER_SEC);
- return 0;
- }
输出结果为:1000
- //Ubuntu
- #include <stdio.h>
- #include <unistd.h>
- #include <sys/times.h>
- int main(int argc,char* argv[])
- {
- int sec_per_dida = sysconf( _SC_CLK_TCK);
- printf("%d\n", sec_per_dida);
- return 0;
- }
输出结果为:100
time的例子:
- #include <stdio.h>
- #include <windows.h>
- #include <time.h>
- int main()
- {
- long beg;
- long end;
- beg = time(0);
- Sleep(5000);
- end = time(0);
- printf("%ld\n", end - beg);
- return 0;
- }
输出结果为5,可知time返回的单位是滴答。
- clock time times
- [DirectShow] 021 - Clock Times
- clock 、times 、gettimeofday
- clock,clock_t,times的注意事项
- wall clock time(response time)
- time & clock(MSDN)
- Wall clock time
- Real-time clock alarm
- clock()与time()区别
- Linux Clock & Time
- Linux Clock & Time
- clock() / time() 函数
- 什么是wall clock time
- CPU vs Clock Time
- Powershell control retry times and sleep time
- dsPIC33F之Real-Time Clock
- linux中的wall clock time
- Python时间性能测量 time.clock() time.time() timeit.timeit()
- 库存转储订单及移动类型
- c++ prime+查询程序设计
- 关闭UITableView cell的被选中效果
- 无价值工厂怎么建立的
- iPhone & iPad高级编程(35年编程经验结晶之作,案例源码免费下载)
- clock time times
- 详解“未能确定工厂的发运数据”原因
- 自定义UINavigationBar的背景图片
- CCIR656 .
- 图像处理和图像识别中常用的OpenCV函数
- JNDI概念
- 迅雷云点播源码分析与修改
- 学会重构你的代码
- 大三总结