Boost學習筆記(三) progress_timer

   progress_timer也是一個計時器,它繼承自timer,會在析構時自動輸出時間,省去timer手動調用elapsed()的工做,是一個用於自動計時至關方便的小工具。ios

      

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

int main()
{
     boost::progress_timer     t;  //聲明一個計時器,開始計時
    //dosomething
     for(int i=0;i<100;i++)
     {
         cout<<"a";
     }
}

  運行上面代碼,在退出(離開main函數)時會致使progress_tiimer析構時,會自動輸出流逝時間。函數

相關文章
相關標籤/搜索