计算程序运行时间,精确到毫秒级
2015-08-03 10:22
295 查看
#include <sys/timeb.h>
#if defined(WIN32)
# define TIMEB _timeb
# define ftime _ftime
#else
#define TIMEB timeb
#endif
time_t ltime1, ltime2, tmp_time;
struct TIMEB tstruct1, tstruct2;
ftime (&tstruct1); // start time ms
time (<ime1); // start time s
//work
time (<ime2); // end time sec
ftime (&tstruct2); // end time ms
tmp_time = (ltime2 * 1000 + tstruct2.millitm) - (ltime1 * 1000 + tstruct1.millitm);
#if defined(WIN32)
# define TIMEB _timeb
# define ftime _ftime
#else
#define TIMEB timeb
#endif
time_t ltime1, ltime2, tmp_time;
struct TIMEB tstruct1, tstruct2;
ftime (&tstruct1); // start time ms
time (<ime1); // start time s
//work
time (<ime2); // end time sec
ftime (&tstruct2); // end time ms
tmp_time = (ltime2 * 1000 + tstruct2.millitm) - (ltime1 * 1000 + tstruct1.millitm);
相关文章推荐
- 你是码农还是优秀程序员?
- GCC 64位程序的makefile条件编译心得——32位版与64位版、debug版与release版(兼容MinGW、TDM-GCC)
- Server Tomcat v7.0 Server at localhost failed to start
- java Map接口源码分析
- 南邮 OJ 1017 乘积最大
- spring事物管理
- [二分]poj3061 Susequence
- COPY 系统吞吐量(TPS)、用户并发量、性能测试概念和公式
- block为什么用copy关键字
- sqlserver插入方法
- 个人笔记
- Version of activiti database (5.15.1) is more recent than the engine (5.14)
- JAVA获取IP地址和本机IP地址的工具类
- python的一些机器学习算法库
- 自绘制View---------左右滑动刻度调频View
- JDBC杂记学习
- 用智能指针管理容器及内存紧凑
- 最长回文
- Extjs DateField Bug 当format为年月'Y-m',在当前月(30、31号)选择其他偶数月会乱跳的问题解决方案
- 最长回文 分类: 串 2015-08-03 10:20 5人阅读 评论(0) 收藏