21 #include <gtsam/dllexport.h> 22 #include <gtsam/config.h> 24 #include <boost/smart_ptr/shared_ptr.hpp> 25 #include <boost/smart_ptr/weak_ptr.hpp> 26 #include <boost/version.hpp> 110 #if BOOST_VERSION >= 104800 111 # ifndef GTSAM_DISABLE_NEW_TIMERS 112 # define GTSAM_USING_NEW_BOOST_TIMERS 116 #ifdef GTSAM_USING_NEW_BOOST_TIMERS 117 # include <boost/timer/timer.hpp> 119 # include <boost/timer.hpp> 124 # include <tbb/tick_count.h> 137 GTSAM_EXPORT
void tic(
size_t id,
const char *label);
140 GTSAM_EXPORT
void toc(
size_t id,
const char *label);
164 #ifdef GTSAM_USING_NEW_BOOST_TIMERS 165 boost::timer::cpu_timer
timer_;
171 tbb::tick_count tbbTimer_;
173 void add(
size_t usecs,
size_t usecsWall);
177 GTSAM_EXPORT
TimingOutline(
const std::string& label,
size_t myId);
178 GTSAM_EXPORT
size_t time()
const;
179 double secs()
const {
return double(
time()) / 1000000.0;}
180 double self()
const {
return double(t_) / 1000000.0;}
181 double wall()
const {
return double(tWall_) / 1000000.0;}
182 double min()
const {
return double(tMin_) / 1000000.0;}
183 double max()
const {
return double(tMax_) / 1000000.0;}
184 double mean()
const {
return self() /
double(n_); }
185 GTSAM_EXPORT
void print(
const std::string& outline =
"")
const;
186 GTSAM_EXPORT
void print2(
const std::string& outline =
"",
const double parentTotal = -1.0)
const;
187 GTSAM_EXPORT
const boost::shared_ptr<TimingOutline>&
188 child(
size_t child,
const std::string& label,
const boost::weak_ptr<TimingOutline>& thisPtr);
189 GTSAM_EXPORT
void tic();
190 GTSAM_EXPORT
void toc();
193 GTSAM_EXPORT
friend void toc(
size_t id,
const char *label);
207 : id_(id), label_(label), isSet_(true) {
230 #define gttic_(label) \ 231 static const size_t label##_id_tic = ::gtsam::internal::getTicTocID(#label); \ 232 ::gtsam::internal::AutoTicToc label##_obj(label##_id_tic, #label) 235 #define gttoc_(label) \ 239 #define longtic_(label) \ 240 static const size_t label##_id_tic = ::gtsam::internal::getTicTocID(#label); \ 241 ::gtsam::internal::ticInternal(label##_id_tic, #label) 244 #define longtoc_(label) \ 245 static const size_t label##_id_toc = ::gtsam::internal::getTicTocID(#label); \ 246 ::gtsam::internal::tocInternal(label##_id_toc, #label) 261 #define tictoc_getNode(variable, label) \ 262 static const size_t label##_id_getnode = ::gtsam::internal::getTicTocID(#label); \ 263 const boost::shared_ptr<const ::gtsam::internal::TimingOutline> variable = \ 264 ::gtsam::internal::gCurrentTimer.lock()->child(label##_id_getnode, #label, ::gtsam::internal::gCurrentTimer); 272 #define gttic(label) gttic_(label) 273 #define gttoc(label) gttoc_(label) 274 #define longtic(label) longtic_(label) 275 #define longtoc(label) longtoc_(label) 276 #define tictoc_finishedIteration tictoc_finishedIteration_ 277 #define tictoc_print tictoc_print_ 278 #define tictoc_reset tictoc_reset_ 280 #define gttic(label) ((void)0) 281 #define gttoc(label) ((void)0) 282 #define longtic(label) ((void)0) 283 #define longtoc(label) ((void)0) 284 #define tictoc_finishedIteration() ((void)0) 285 #define tictoc_print() ((void)0) 286 #define tictoc_reset() ((void)0)
double t2_
cache the t_i^2
GTSAM_EXTERN_EXPORT boost::shared_ptr< TimingOutline > gTimingRoot
Typedefs for easier changing of types.
GTSAM_EXPORT const boost::shared_ptr< TimingOutline > & child(size_t child, const std::string &label, const boost::weak_ptr< TimingOutline > &thisPtr)
GTSAM_EXPORT void finishedIteration()
GTSAM_EXTERN_EXPORT boost::weak_ptr< TimingOutline > gCurrentTimer
double wall() const
wall time, in seconds
gtsam::ValueWithDefault< bool, false > timerActive_
void toc(size_t id, const char *label)
AutoTicToc(size_t id, const char *label)
double min() const
min time, in seconds
GTSAM_EXPORT void print(const std::string &outline="") const
void tic(size_t id, const char *labelC)
GTSAM_EXPORT size_t time() const
time taken, including children
double secs() const
time taken, in seconds, including children
GTSAM_EXPORT TimingOutline(const std::string &label, size_t myId)
Constructor.
void add(size_t usecs, size_t usecsWall)
size_t getTicTocID(const char *descriptionC)
double max() const
max time, in seconds
A thin wrapper around std::map that uses boost's fast_pool_allocator.
FastMap< size_t, boost::shared_ptr< TimingOutline > > ChildMap
double mean() const
mean self time, in seconds
void tictoc_finishedIteration_()
GTSAM_EXPORT void print2(const std::string &outline="", const double parentTotal=-1.0) const
boost::weak_ptr< TimingOutline > parent_
parent pointer
ChildMap children_
subtrees