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> 137 GTSAM_EXPORT
size_t getTicTocID(
const char *description);
140 GTSAM_EXPORT
void tic(
size_t id,
const char *label);
143 GTSAM_EXPORT
void toc(
size_t id,
const char *label);
159 size_t lastChildOrder_;
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();
206 GTSAM_EXPORT
void finishedIteration();
208 GTSAM_EXPORT
friend void toc(
size_t id,
const char *label);
222 : id_(
id), label_(label), isSet_(
true) {
234 GTSAM_EXTERN_EXPORT std::shared_ptr<TimingOutline> gTimingRoot;
235 GTSAM_EXTERN_EXPORT std::weak_ptr<TimingOutline> gCurrentTimer;
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) 264 inline void tictoc_finishedIteration_() {
265 ::gtsam::internal::gTimingRoot->finishedIteration(); }
268 inline void tictoc_print_() {
269 ::gtsam::internal::gTimingRoot->print(); }
272 inline void tictoc_print2_() {
273 ::gtsam::internal::gTimingRoot->print2(); }
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); 282 inline void tictoc_reset_() {
283 ::gtsam::internal::gTimingRoot.reset(new ::gtsam::internal::TimingOutline(
"Total", ::gtsam::internal::getTicTocID(
"Total")));
284 ::gtsam::internal::gCurrentTimer = ::gtsam::internal::gTimingRoot; }
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
Definition: timing.h:197
double t2_
cache the
Definition: timing.h:153
Typedefs for easier changing of types.
double secs() const
time taken, in seconds, including children
Definition: timing.h:185
double min() const
min time, in seconds
Definition: timing.h:196
double wall() const
wall time, in seconds
Definition: timing.h:195
GTSAM_EXPORT size_t time() const
time taken, including children
std::weak_ptr< TimingOutline > parent_
parent pointer
Definition: timing.h:163
Definition: chartTesting.h:28
A thin wrapper around std::map that uses boost's fast_pool_allocator.
double mean() const
mean self time, in seconds
Definition: timing.h:198
ChildMap children_
subtrees
Definition: timing.h:165
GTSAM_EXPORT TimingOutline(const std::string &label, size_t myId)
Constructor.