【Boost】系列01:时间与日期

timer库(含timer,progress_timer和progress_display三个组件)和date_time

timer用法:

#include <boost/timer.hpp>
#include <iostream>
using namespace std;
using namespace boost;

int main()
{
    timer t;//开始计时
    cout<<"max timespan:"<<t.elapsed_max()/3600<<"h"<<endl;
    cout<<"min timespan:"<<t.elapsed_min()<<"s"<<endl;

    for(int i=0;i<5000000;i++);
    cout<<"now time elapsed:"<<t.elapsed()<<"s"<<endl;
    return 0;
}

progress_timer继承于timer,在析构时会自动输出时间。

原文地址:https://www.cnblogs.com/elesos/p/2756288.html