#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. 走过的K8S坑

    基本的docker命令: docker 镜像 打包成文件 sudo docker save -o 打包后的文件名 {镜像ID}或者{镜像标签} docker 改名: docker tag ff2816 ...

  2. 吴裕雄 python 神经网络——TensorFlow训练神经网络:MNIST最佳实践

    import os import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_N ...

  3. CPI 3.0磁盘空间不足!

    当使用Cisco PI的时候,有的时候可能出现diskspace不够的情况,这种情况可能是前期部署PI的时候,提供的空间太小了,或者目前缓存的数据太多了. 如下是一个例子: 在CLI中检查时,PI数据 ...

  4. CF10D LCIS 最长公共上升子序列

    题目描述 This problem differs from one which was on the online contest. The sequence a1,a2,...,an a_{1}, ...

  5. how to analyze jmeter results

    https://octoperf.com/blog/2017/10/19/how-to-analyze-jmeter-results/

  6. 275 原型与原型链:显式原型prototype ,隐式原型__proto__,隐式原型链,原型链_属性问题,给原型对象添加属性/方法

    1.所有函数都有一个特别的属性 prototype : 显式原型属性 [普通构造函数的实例对象没有prototype 属性,构造函数有__proto__属性,原型对象有__proto__属性 ] 2. ...

  7. vue通过get方法下载java服务器excel模板

    vue方法 handleDownTemplateXls(fileName){ if(!fileName || typeof fileName != "string"){ fileN ...

  8. iOS开发应用上架必读最新苹果审核规则(史上最全版)

    官方文档 地址https://developer.apple.com/cn/app-store/review/guidelines/ App Store 审核指南 简介 App 正在改变世界,丰富人们 ...

  9. LIBRA查询

    SELECT COUNT(1)FROM rawdata_vehiclepassing xWHERE x.passingtime >= to_date('2019-11-24,00:00:00', ...

  10. 复盘实战营一期毕业典礼----HHR计划----以太入门课--第一课

    你要永远记住,实事求是. 我好像没能力给大家分享什么.分享点我的专业知识吧.我是做推荐+增长的,在一家D轮 DAU快千万的创业公司做增长优化负责人.一路优化,我把人均时长提高了30多分钟(现在人均时长 ...