#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. slf4j-api整合maven 工程日志配置文件

    springmvc项目 pom.xml: <dependency> <groupId>org.slf4j</groupId> <artifactId>s ...

  2. 树莓派Ubuntu Mate 16.04 修改为国内更新源

    收藏:https://blog.csdn.net/wang_shuai_ww/article/details/80386708 更换步骤以root身份打开 /etc/apt/sources.list ...

  3. 路由器安全-NetFlow

    1.NetFlow介绍 提供高层次的诊断,分类和识别网络异常. 使用NetFlow来检查哪些行为改变明显的攻击是非常有效的. 就像Wiretap一样捕获数据包. NetFlow像电话账单.(谁和谁在通 ...

  4. 有个网站秒破mdb访问密码

    http://tools.bugscaner.com/crackmdb/网站

  5. ES2.3.5版本的数据类型

    1,最近使用了2.3.5版本的ES,发现在创建索引的时候出了以下错误. (1)例: POST 192.168.11.166:9200/article3/article/_mapping { " ...

  6. From scratch 资源

    neural-network-from-scratch:https://github.com/pangolulu/neural-network-from-scratch rnn-from-scratc ...

  7. VS release模式下进行调试设置

    工程项目上右键 打开 属性界面 1.c++ ---  常规 ---- 调试信息格式 选  程序数据库(/Zi)或(/ZI), 注意:如果是库的话,只能(Zi) 2.c/c++ ---- 优化 ---- ...

  8. Java Web 前端资源文件的路径问题

    WEB-INF是Java Web应用的安全目录,在部署时用于存放class文件.项目用到的库(jar包).Java Web应用的配置文件web.xml. 浏览器不能访问此目录下的资源,比如在WEB-I ...

  9. JavaScript 引擎「V8」发布 8.0 版本,内存占用量大幅下降

    上周,JavaScript 引擎「V8」的开发团队在该项目官方网站上正式宣布推出最新的 8.0 版本.这次更新的重点主要集中在错误修复及性能改善上,正式的版本将在数周后随着谷歌 Chrome 80 稳 ...

  10. Java通过反射实现实例化

    public static void main(String[] args) throws Exception { User user= (User) test(User.class); System ...