43 #pragma GCC system_header
49 #include <boost/date_time/posix_time/posix_time.hpp>
79 boost::posix_time::ptime end_time = boost::posix_time::microsec_clock::local_time ();
80 return (static_cast<double> (((end_time -
start_time_).total_milliseconds ())));
94 start_time_ = boost::posix_time::microsec_clock::local_time ();
120 title_ (
std::string (title))
122 start_time_ = boost::posix_time::microsec_clock::local_time ();
126 title_ (
std::string (
""))
128 start_time_ = boost::posix_time::microsec_clock::local_time ();
134 std::cerr << title_ <<
" took " << val <<
"ms.\n";
142 #ifndef MEASURE_FUNCTION_TIME
143 #define MEASURE_FUNCTION_TIME \
144 ScopeTime scopeTime(__func__)
150 boost::posix_time::ptime epoch_time (boost::gregorian::date (1970, 1, 1));
151 boost::posix_time::ptime current_time = boost::posix_time::microsec_clock::local_time ();
152 return (static_cast<double>((current_time - epoch_time).total_nanoseconds ()) * 1.0e-9);
157 #define DO_EVERY_TS(secs, currentTime, code) \
159 static double s_lastDone_ = 0.0; \
160 double s_now_ = (currentTime); \
161 if (s_lastDone_ > s_now_) \
162 s_lastDone_ = s_now_; \
163 if ((s_now_ - s_lastDone_) > (secs)) { \
165 s_lastDone_ = s_now_; \
173 #define DO_EVERY(secs, code) \
174 DO_EVERY_TS(secs, pcl::getTime(), code)
180 #endif //#ifndef PCL_NORMS_H_
virtual ~StopWatch()
Destructor.
Class to measure the time spent in a scope.
ScopeTime(const char *title)
boost::posix_time::ptime start_time_
void reset()
Reset the stopwatch to 0.
double getTimeSeconds()
Retrieve the time in seconds spent since the last call to reset().
double getTime()
Retrieve the time in milliseconds spent since the last call to reset().