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> 134 GTSAM_EXPORT
size_t getTicTocID(
const char *description);
137 GTSAM_EXPORT
void tic(
size_t id,
const char *label);
140 GTSAM_EXPORT
void toc(
size_t id,
const char *label);
156 size_t lastChildOrder_;
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);
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 void print(
const std::string& outline =
"")
const;
186 void print2(
const std::string& outline =
"",
const double parentTotal = -1.0)
const;
187 const boost::shared_ptr<TimingOutline>&
188 child(
size_t child,
const std::string& label,
const boost::weak_ptr<TimingOutline>& thisPtr);
191 void finishedIteration();
193 GTSAM_EXPORT
friend void toc(
size_t id,
const char *label);
207 : id_(
id), label_(label), isSet_(
true) {
219 GTSAM_EXTERN_EXPORT boost::shared_ptr<TimingOutline> gTimingRoot;
220 GTSAM_EXTERN_EXPORT boost::weak_ptr<TimingOutline> gCurrentTimer;
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) 249 inline void tictoc_finishedIteration_() {
250 ::gtsam::internal::gTimingRoot->finishedIteration(); }
253 inline void tictoc_print_() {
254 ::gtsam::internal::gTimingRoot->print(); }
257 inline void tictoc_print2_() {
258 ::gtsam::internal::gTimingRoot->print2(); }
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); 267 inline void tictoc_reset_() {
268 ::gtsam::internal::gTimingRoot.reset(new ::gtsam::internal::TimingOutline(
"Total", ::gtsam::internal::getTicTocID(
"Total")));
269 ::gtsam::internal::gCurrentTimer = ::gtsam::internal::gTimingRoot; }
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 \sum t_i^2
Definition: timing.h:150
double secs() const
time taken, in seconds, including children
Definition: timing.h:179
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
Timing Entry, arranged in a tree.
Definition: timing.h:145
double wall() const
wall time, in seconds
Definition: timing.h:181
A thin wrapper around std::map that uses boost's fast_pool_allocator.
double max() const
max time, in seconds
Definition: timing.h:183
ChildMap children_
subtrees
Definition: timing.h:162
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
boost::weak_ptr< TimingOutline > parent_
parent pointer
Definition: timing.h:160
double min() const
min time, in seconds
Definition: timing.h:182
double mean() const
mean self time, in seconds
Definition: timing.h:184
Small class that calls internal::tic at construction, and internol::toc when destroyed.
Definition: timing.h:199
Typedefs for easier changing of types.