C 标准库 —— time.h
2016-05-11 18:00
411 查看
C 标准库—— string.h
C 标准库 —— time.h
C 标准库 —— limits.h
C 标准库 —— stdio.h
C 标准库—— stdlib.h(包括 rand srand 的实现)
C 标准库——<cmath>/<math.h>
C 标准库—— assert.h
也即
(2)ctime() ⇒ 把参数转换为当地时间
宏 CLOCKS_PER_SEC:每秒钟包含多少个时钟单元数(#define CLOCKS_PER_SEC ((clock_t)1000)
C 标准库 —— time.h
C 标准库 —— limits.h
C 标准库 —— stdio.h
C 标准库—— stdlib.h(包括 rand srand 的实现)
C 标准库——<cmath>/<math.h>
C 标准库—— assert.h
time_t
typedef __time32_t time_t; typedef __int32 __time32_t; # define __int32 long // 也即 time_t 其实是 32 位 long 类型
也即
time_t可取的最大值为:0x7fffffff。
time_t biggest = 0x7fffffff; printf("biggest = %d\n", biggest);
1. 基本类型定义及 API
(1)time() ⇒ 获取当前时间、time_t now = time(0); printf("now is: %s\n", ctime(&now)); // now: Wed May 11 12:55:09 2016
(2)ctime() ⇒ 把参数转换为当地时间
time_t biggest = 0x7fffffff; printf("biggest: %s", ctime(&biggest)); // biggest: Tue Jan 19 11:14:07 2038
2. 运行时间
使用 clock() 函数:返回从程序运行时刻开始的时钟周期数,返回值为 (typedef long clock_t);宏 CLOCKS_PER_SEC:每秒钟包含多少个时钟单元数(#define CLOCKS_PER_SEC ((clock_t)1000)
clock_t start_time = clock(); // 待测代码段 cout << "elpsed time(ms): " << static_cast<double>(clock() - start_time)/CLOCKS_PER_SEC * 1000 << endl;
相关文章推荐
- Jquery 多选下拉框取值
- Elasticsearch源码分析九--查询解析器QueryParser注册过程
- NSTableView 单击 双击 事件
- [随笔] 项目性能追踪 之 structs & spring 的拦截器
- window.frames在不同浏览器中的用法
- window.frames在不同浏览器中的用法
- html中META标签的作用及SEO关键字优化办法
- 基于HTK的连续语音识别系统搭建学习笔记(一)
- httpclient4.3发送post和get实例代码
- ssm 框架集成memcached 缓存服务器
- Jquery下拉框取值
- CSS学习(九)——构造颜色、背景和图像
- HDU4162 Shape Number(字符串最小表示法)
- iOS开发之常用的加密方法
- HDU 5245 Joyful 经典概率题目推公式
- 【C#设计模式-备忘录模式】
- 对cnblogs.com的用户体验
- 秒杀系统架构优化思路 | 哈巴狗
- Undefined symbols for architecture arm64:
- 异步get请求之代理方法