#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. 解决游览器安装Vue.js devtools插件无效的问题

    一: 打开自己写的一个vue.js网页,发现这个图标并没有亮起来,还是灰色 解决方案:  1.我们先看看Vue.js devtools是否生效,打开Bilibili(https://www.bilib ...

  2. Ext插件中控件的xtype和类的对应关系总结

    xtype Class ------------- ------------------ box Ext.BoxComponent button Ext.Button buttongroup Ext. ...

  3. Codeforces Round #617 (Div. 3)

    A 题意:能否将数组里面的值用数组里面的值替换出一个和为奇数的数组 思路:1.和为奇数yes 2.和为偶数但有奇数yes 3.个数是奇数的,有奇数的yes 其他都是no 果然罚时全给了A #inclu ...

  4. 15、python面对对象之类和对象

    前言:本文主要介绍python面对对象中的类和对象,包括类和对象的概念.类的定义.类属性.实例属性及实例方法等. 一.类和对象的概念 问题:什么是类?什么是实例对象? 类:是一类事物的抽象概念,不是真 ...

  5. Cake ZOJ - 3537

    题目链接 本题也是区间dp三角剖分板子题,只不过加入了判断是否是凸包,计算顺序要用凸包顺序(凸包板) #include<bits/stdc++.h> using namespace std ...

  6. leetCode练题——13. Roman to Integer

    1.题目13. Roman to Integer Roman numerals are represented by seven different symbols: I, V, X, L, C, D ...

  7. Mysql基本用法-存储引擎-03

    看到存储引擎这个地方感到很多细节比较陌生,所以总结小记一些 为了适应各种不同的运行环境,MYSQL提供了多种不同的存储引擎(Storage Engine ),在应用程序开发这个层面上,开发者可以根据不 ...

  8. selenium webdriver 实现百度贴吧自动签到

    public static void main(String[] args) { //TestUtils.killProcess("javaw.exe"); TestUtils.k ...

  9. Mybatis的逆向工程以及Example的实例函数及详解

    Mybatis-generator是Mybatis的逆向工程  (根据数据库中的表生成java代码) Mybatis的逆向工程会生成实例及实例对应的example,example用于添加条件,相当于w ...

  10. mysql 连接数据库时时区报错

    1.url: jdbc:mysql://192.168.0.101:3306/testdb?serverTimezone=UTC,在连接字符后面添加时区设置 2.使用navicat或者直接使用mysq ...