|
平常测试个PCL算法的效率,常用代码分享了。
#include < ctime >
time_t tstart, tend;
tstart = time(0);
//your scripts
//
//end
tend = time(0);
cout << “It took ” << difftime(tend, tstart) << ” second(s).” << endl;
It worked fine for me.
Well, if you want to be as precise as possible, then use the following C code, which is at microsecond resolution:
#include <time.h>
double tstart, tstop, ttime;
tstart = (double)clock()/CLOCKS_PER_SEC;
/* YOUR CODES */
tstop = (double)clock()/CLOCKS_PER_SEC;
ttime= tstop-tstart; /*ttime is how long your code run */
|
|