cpp 计算程序运行时间的两种方法

1. 

#include <time.h>

time_t begin_t  = clock();
// to do 
time_t finish_t = clock();

cout<<"it cost " << (double )(finish_t - begin_t )/CLOCKS_PER_SEC <<" s"<<endl;

2.

#include <boost/timer.hpp>

boost::timer timer; /
/ to do cout<<" cost time: "<<timer.elapsed() <<endl;

 

posted @ 2017-05-19 17:54  xy123001  阅读(1847)  评论(0编辑  收藏  举报