21 #include <gtsam/dllexport.h> 22 #include <gtsam/config.h> 24 #ifdef GTSAM_USE_BOOST_FEATURES 25 #include <boost/version.hpp> 110 #ifdef GTSAM_USE_BOOST_FEATURES 112 #if BOOST_VERSION >= 104800 113 # ifndef GTSAM_DISABLE_NEW_TIMERS 114 # define GTSAM_USING_NEW_BOOST_TIMERS 118 #ifdef GTSAM_USING_NEW_BOOST_TIMERS 119 # include <boost/timer/timer.hpp> 121 # include <boost/timer.hpp> 127 # include <tbb/tick_count.h> 140 GTSAM_EXPORT
void tic(
size_t id,
const char *label);
143 GTSAM_EXPORT
void toc(
size_t id,
const char *label);
168 #ifdef GTSAM_USE_BOOST_FEATURES 169 #ifdef GTSAM_USING_NEW_BOOST_TIMERS 170 boost::timer::cpu_timer timer_;
176 tbb::tick_count tbbTimer_;
179 void add(
size_t usecs,
size_t usecsWall);
183 GTSAM_EXPORT
TimingOutline(
const std::string& label,
size_t myId);
184 GTSAM_EXPORT
size_t time()
const;
185 double secs()
const {
return double(
time()) / 1000000.0;}
186 #ifdef GTSAM_USE_BOOST_FEATURES 187 double self()
const {
return double(t_) / 1000000.0;}
188 double wall()
const {
return double(tWall_) / 1000000.0;}
189 double min()
const {
return double(tMin_) / 1000000.0;}
190 double max()
const {
return double(tMax_) / 1000000.0;}
191 double mean()
const {
return self() /
double(n_); }
194 double self()
const {
return -1.; }
195 double wall()
const {
return -1.; }
196 double min()
const {
return -1.; }
197 double max()
const {
return -1.; }
198 double mean()
const {
return -1.; }
200 GTSAM_EXPORT
void print(
const std::string& outline =
"")
const;
201 GTSAM_EXPORT
void print2(
const std::string& outline =
"",
const double parentTotal = -1.0)
const;
202 GTSAM_EXPORT
const std::shared_ptr<TimingOutline>&
203 child(
size_t child,
const std::string& label,
const std::weak_ptr<TimingOutline>& thisPtr);
204 GTSAM_EXPORT
void tic();
205 GTSAM_EXPORT
void toc();
208 GTSAM_EXPORT
friend void toc(
size_t id,
const char *label);
222 : id_(id), label_(label), isSet_(true) {
245 #define gttic_(label) \ 246 static const size_t label##_id_tic = ::gtsam::internal::getTicTocID(#label); \ 247 ::gtsam::internal::AutoTicToc label##_obj(label##_id_tic, #label) 250 #define gttoc_(label) \ 254 #define longtic_(label) \ 255 static const size_t label##_id_tic = ::gtsam::internal::getTicTocID(#label); \ 256 ::gtsam::internal::ticInternal(label##_id_tic, #label) 259 #define longtoc_(label) \ 260 static const size_t label##_id_toc = ::gtsam::internal::getTicTocID(#label); \ 261 ::gtsam::internal::tocInternal(label##_id_toc, #label) 276 #define tictoc_getNode(variable, label) \ 277 static const size_t label##_id_getnode = ::gtsam::internal::getTicTocID(#label); \ 278 const std::shared_ptr<const ::gtsam::internal::TimingOutline> variable = \ 279 ::gtsam::internal::gCurrentTimer.lock()->child(label##_id_getnode, #label, ::gtsam::internal::gCurrentTimer); 287 #define gttic(label) gttic_(label) 288 #define gttoc(label) gttoc_(label) 289 #define longtic(label) longtic_(label) 290 #define longtoc(label) longtoc_(label) 291 #define tictoc_finishedIteration tictoc_finishedIteration_ 292 #define tictoc_print tictoc_print_ 293 #define tictoc_reset tictoc_reset_ 295 #define gttic(label) ((void)0) 296 #define gttoc(label) ((void)0) 297 #define longtic(label) ((void)0) 298 #define longtoc(label) ((void)0) 299 #define tictoc_finishedIteration() ((void)0) 300 #define tictoc_print() ((void)0) 301 #define tictoc_reset() ((void)0) double max() const
max time, in seconds
Typedefs for easier changing of types.
GTSAM_EXPORT size_t time() const
time taken, including children
double secs() const
time taken, in seconds, including children
GTSAM_EXPORT void finishedIteration()
void toc(size_t id, const char *labelC)
FastMap< size_t, std::shared_ptr< TimingOutline > > ChildMap
AutoTicToc(size_t id, const char *label)
double min() const
min time, in seconds
void tic(size_t id, const char *labelC)
GTSAM_EXPORT void print2(const std::string &outline="", const double parentTotal=-1.0) const
double wall() const
wall time, in seconds
GTSAM_EXPORT const std::shared_ptr< TimingOutline > & child(size_t child, const std::string &label, const std::weak_ptr< TimingOutline > &thisPtr)
GTSAM_EXTERN_EXPORT std::shared_ptr< TimingOutline > gTimingRoot
GTSAM_EXPORT TimingOutline(const std::string &label, size_t myId)
Constructor.
void add(size_t usecs, size_t usecsWall)
std::weak_ptr< TimingOutline > parent_
parent pointer
size_t getTicTocID(const char *descriptionC)
A thin wrapper around std::map that uses boost's fast_pool_allocator.
GTSAM_EXTERN_EXPORT std::weak_ptr< TimingOutline > gCurrentTimer
double mean() const
mean self time, in seconds
void tictoc_finishedIteration_()
ChildMap children_
subtrees
GTSAM_EXPORT void print(const std::string &outline="") const