博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一个不错的计时器类
阅读量:4350 次
发布时间:2019-06-07

本文共 1412 字,大约阅读时间需要 4 分钟。

1 /*  2 * Timer Class  3 * By Danny Battison  4 * gabehabe@hotmail.com  5 */  6  7 #include 
8 9 class CTimer 10 {
11 public: // everything is public for ease of access 12 // begin/end variables 13 clock_t begin; 14 clock_t end; 15 16 // variable declarations used for time calculation 17 double elapTicks; 18 double elapMilli, elapSeconds, elapMinutes; 19 20 // constructor 21 CTimer () {} 22 //call myTimer.begin () to begin the timer 23 void start() 24 {
25 this->begin = clock () * CLK_TCK; 26 } 27 // call myTimer.stop () to stop the timer 28 void stop () 29 {
30 this->end = clock () * CLK_TCK; getTimes (); 31 } 32 33 // call getTimes 34 void getTimes () 35 {
36 // variable definitions on to calculate time taken 37 this->elapTicks = this->end - this->begin; // stop the timer, and calculete the time taken 38 this->elapMilli = this->elapTicks/1000; //milliseconds from Begin to End 39 this->elapSeconds = this->elapMilli/1000; //seconds from Begin to End 40 this->elapMinutes = this->elapSeconds/60; //minutes from Begin to End 41 } 42 };

转载于:https://www.cnblogs.com/JohnShao/archive/2011/08/24/2151468.html

你可能感兴趣的文章
软件设计
查看>>
Hadoop各种进程的配置文件及其位置说明
查看>>
js时间戳转时间格式
查看>>
Nginx配置文件nginx.conf中文详解(总结)
查看>>
Linux的用户态和内核态
查看>>
JavaScript原生错误及检测
查看>>
(原创) cocos2d-x 3.0+ lua 学习和工作(4) : 公共函数(3): 深度克隆clone()
查看>>
为什么写作
查看>>
整数子数组求最大和添加验证
查看>>
使用kubeadm安装Kubernetes
查看>>
Principal Component Analysis 主元分析
查看>>
JDBC原生态代码
查看>>
韩版可爱小碎花创意家居收纳挂袋
查看>>
计算机基础之硬件
查看>>
python操作mysql ------- SqlAchemy正传
查看>>
如何使用 JSP JSTL 显示/制作树(tree) 菜单
查看>>
12.5号
查看>>
lintcode-medium-Binary Tree Zigzag Level Order Traversal
查看>>
logrotate日志切割
查看>>
POJ-3253 Fence Repair 贪心
查看>>