43 #pragma GCC system_header
48 #include <boost/date_time/posix_time/posix_time.hpp>
77 boost::posix_time::ptime end_time = boost::posix_time::microsec_clock::local_time ();
78 return (static_cast<double> (((end_time -
start_time_).total_milliseconds ())));
92 start_time_ = boost::posix_time::microsec_clock::local_time ();
118 title_ (
std::string (title))
120 start_time_ = boost::posix_time::microsec_clock::local_time ();
124 title_ (
std::string (
""))
126 start_time_ = boost::posix_time::microsec_clock::local_time ();
132 std::cerr << title_ <<
" took " << val <<
"ms.\n";
140 #ifndef MEASURE_FUNCTION_TIME
141 #define MEASURE_FUNCTION_TIME \
142 ScopeTime scopeTime(__func__)
148 boost::posix_time::ptime epoch_time (boost::gregorian::date (1970, 1, 1));
149 boost::posix_time::ptime current_time = boost::posix_time::microsec_clock::local_time ();
150 return (static_cast<double>((current_time - epoch_time).total_nanoseconds ()) * 1.0e-9);
155 #define DO_EVERY_TS(secs, currentTime, code) \
157 static double s_lastDone_ = 0.0; \
158 double s_now_ = (currentTime); \
159 if (s_lastDone_ > s_now_) \
160 s_lastDone_ = s_now_; \
161 if ((s_now_ - s_lastDone_) > (secs)) { \
163 s_lastDone_ = s_now_; \
171 #define DO_EVERY(secs, code) \
172 DO_EVERY_TS(secs, pcl::getTime(), code)
178 #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().