点云库PCL学习笔记 -- 输入输出IO -- 6.PCL中记录时间长度TicToc 类和系统Time 类
PCL库中用于记录时间长度的方法
第一种:TicToc 类的方法
#include <pcl/console/time.h>
pcl::console::TicToc tt;
tt.tic ();
//-------------------------------------------------------------------------------
//写入需要记录执行多长时间的代码(即需要计时的事件)
//-------------------------------------------------------------------------------
std::cout << "[done, " << tt.toc () << " ms ]" << std::endl;
简化版本
#include <pcl/console/time.h>
using namespace pcl::console;
//类似的子函数程序段
void
TestProcess(int a, int b)
{
TicToc tt;
//-------------------------------------------------------------------------------
//写入需要记录执行多长时间的代码(即需要计时的事件)
//-------------------------------------------------------------------------------
std::cout << "[done, " << tt.toc () << " ms ]" << std::endl;
}
第二种:系统Time 类的方法
注意:如果是在Linux系统
下,需要调用的头文件为#include <time.h>
在Win系统
下,需要调用的头文件为#include <ctime>
#include <time.h>
int main(int argc, char** argv)
{
time_t begin, end;
begin = clock(); //开始计时
//-------------------------------------------------------------------------------
//写入需要计时执行的程序
//-------------------------------------------------------------------------------
end = clock(); //结束计时
double Times = double(end - begin) / CLOCKS_PER_SEC; //将clock()函数的结果转化为以秒为单位的量
std::cout << "time: " << Times << "s" << std::endl;
return 0;
}