初入boost,沿着博主的思路研究源码
C++ | boost库入门_boost c++-优快云博客
timer库
timer是小型的计时器,不适用于高精度的时间测量任务,它的精度依赖操作系统或编译器,难以做到跨平台。timer也不适用于测量大跨度时间段,如果需要以天、月,甚至年为时间单位则不能使用timer,应使用的cpu_timer组件。
使用timer简单示例
#include <iostream>
#include <Windows.h>
#include "boost/timer.hpp"
void TestTimer()
{
boost::timer _timer;
//返回 timer 能够测量的最小时间范围
std::cout << _timer.elapsed_min() << std::endl;
//elapsed()函数可以返回 timer 能够测量的最大时间范围
std::cout << _timer.elapsed_max() << std::endl;
Sleep(1000);
//elapsed()函数可以简单测量自对象创建之后所用的时间
std::cout << _timer.elapsed() << std::endl;
}
int main()
{
TestTimer();
}