欢迎访问我的独立博客

【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,在析构时会自动输出时间。

posted @ 2012-11-06 08:37  github.com/starRTC  阅读(180)  评论(0编辑  收藏  举报