#include <iostream>
#include <boost/timer.hpp> //timer的头文件
using namespace boost; //打开boost名字空间 int main(int argc, char** argv)
{
timer t; //定义一个计时器对象,并开始计时
/*可度量的最大时间,以小时为单位*/
std::cout << "max timespan:" << t.elapsed_max() / 3600 << "h" << std::endl;
/*可度量的最大时间,以小时为单位*/
std::cout << "min timespan:" << t.elapsed_min() << std::endl;
/*输出已经流逝的时间*/
std::cout << "now time elapsed:" << t.elapsed() << "s" << std::endl;
return 0;
}

输出效果:

注意:

  1. 不适合高精度的时间测量
  2. 精度依赖操作系统与编译器,不好做跨平台
  3. 不合适大跨度时间段的测量,因为有最大时间跨度,elapsed_max()可获取

boost::timer demo的更多相关文章

  1. boost::timer库使用

    boost::timer boost库定时器使用,需要在编译时加相关链接库 -lboost_timer -lboost_system boost::timer::cpu_timer 和boost::t ...

  2. boost timer

    Boost.Timer provides clocks to measure code performance. At first, it may seem like this library com ...

  3. boost timer 定时器 Operation cancel !

    前面段时间处理一个定时器时,老是提示 操作取消. 硬是没搞明白为什么! 其实我遇到的这个情况很简单就是(boost::asio::deadline_timer timer)这个变量的生命同期结束了,对 ...

  4. boost timer代码学习笔记

    socket连接中需要判断超时 所以这几天看了看boost中计时器的文档和示例 一共有五个例子 从简单的同步等待到异步调用超时处理 先看第一个例子 // timer1.cpp: 定义控制台应用程序的入 ...

  5. java.util.Timer demo good

    package timer; import java.util.Date; import java.util.Timer; import java.util.TimerTask; import org ...

  6. boost::thread demo

    #include <iostream> #include <boost/date_time/gregorian/gregorian.hpp> #include <boos ...

  7. 初探boost之timer库学习笔记

    timer   使用方法     #include <boost/timer.hpp> #include <iostream> using namespace std; usi ...

  8. boost 学习笔记 2: timer

    boost 学习笔记 2: timer copy from:http://einverne.github.io/post/2015/12/boost-learning-note-2.html 1:ti ...

  9. boost之时间timer

    C++一直缺乏对时间和日期的处理能力,一般借助于C的struct tm和time():timer包含三个类其中timer,progress_timer是计时器类,进度指示类是progress_disp ...

随机推荐

  1. 【知识学习】PHP实现批量替换字典后缀

    <?php //要打开字典的物理路径 $filename = 'E:\Local Test\WWW\password.txt'; $handle = fopen($filename,'r') o ...

  2. 【代码总结】PHP之会话跟踪技术

    有些时候感觉自己学习的效率好低,一套教程一本书,反复听,反复看,反复敲代码.自学这条路真的是很艰难,在任何事情都没有成功之前都很枯燥乏味.自学的过程中总会遇到很多问题,有时候连错误的原因都找不出来,那 ...

  3. CDH 搭建 问题

    1.  问题描述: java.sql.SQLException: Access denied for user 'xxx'@'xxx.xxx.xxx.xxx' (using password: YES ...

  4. 牛客跨年AK场-小sum的假期安排

    链接:https://ac.nowcoder.com/acm/contest/3800/G来源:牛客网 题目描述 小 sun 非常喜欢放假,尤其是那种连在一起的长假,在放假的时候小 sun 会感到快乐 ...

  5. 阿里云服务器安装nginx(ubantu16.04)

    下载安装包 sudo wget http://nginx.org/download/nginx-1.15.5.tar.gz 解压缩 tar zxvf nginx-1.15.5.tar.gz 打开目录 ...

  6. 第一周之Hadoop学习(一)

    首先根据网上的教程得搭建一个linux的环境,所以第一部分是下载虚拟机的过程. 参考博客:https://blog.csdn.net/hliq5399/article/details/78193113 ...

  7. thymeleaf 学习笔记(转)

    原文:http://blog.csdn.net/pdw2009/article/details/44410659 thymeleaf,我个人认为是个比较好的模板,性能也比一般的,比如freemaker ...

  8. vue重置data数据

    可以通过this.$data获取当前状态下的data,通过this.$options.data()获取该组件初始状态下的data. 然后只要使用Object.assign(this.$data, th ...

  9. freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]

    FreeMarker template error:The following has evaluated to null or missing:==> product  [in templat ...

  10. C++ — 后缀表达式转表达式树

    2018-07-21 16:57:26 update 建立表达式树的基本思路:方法类似由下而上建立堆的思想,所以时间复杂度为O(n),这样算法就会变得很简单,只用考虑处理需要入栈的节点和栈中的节点即可 ...