21 #include <boost/shared_ptr.hpp>
22 #include <boost/weak_ptr.hpp>
23 #include <boost/version.hpp>
106 #if BOOST_VERSION >= 104800
107 # ifndef GTSAM_DISABLE_NEW_TIMERS
108 # define GTSAM_USING_NEW_BOOST_TIMERS
112 #ifdef GTSAM_USING_NEW_BOOST_TIMERS
113 # include <boost/timer/timer.hpp>
115 # include <boost/timer.hpp>
119 # include <tbb/tick_count.h>
128 GTSAM_EXPORT
size_t getTicTocID(
const char *description);
129 GTSAM_EXPORT
void ticInternal(
size_t id,
const char *label);
130 GTSAM_EXPORT
void tocInternal(
size_t id,
const char *label);
146 size_t lastChildOrder_;
154 #ifdef GTSAM_USING_NEW_BOOST_TIMERS
155 boost::timer::cpu_timer timer_;
161 tbb::tick_count tbbTimer_;
163 void add(
size_t usecs,
size_t usecsWall);
169 double secs()
const {
return double(time()) / 1000000.0;}
170 double self()
const {
return double(t_) / 1000000.0;}
171 double wall()
const {
return double(tWall_) / 1000000.0;}
172 double min()
const {
return double(tMin_) / 1000000.0;}
173 double max()
const {
return double(tMax_) / 1000000.0;}
174 double mean()
const {
return self() /
double(n_); }
175 void print(
const std::string& outline =
"")
const;
176 void print2(
const std::string& outline =
"",
const double parentTotal = -1.0)
const;
177 const boost::shared_ptr<TimingOutline>&
178 child(
size_t child,
const std::string& label,
const boost::weak_ptr<TimingOutline>& thisPtr);
181 void finishedIteration();
183 GTSAM_EXPORT
friend void tocInternal(
size_t id,
const char *label);
195 AutoTicToc(
size_t id,
const char* label) : id_(
id), label_(label), isSet_(
true) { ticInternal(id_, label_); }
196 void stop() { tocInternal(id_, label_); isSet_ =
false; }
200 GTSAM_EXTERN_EXPORT boost::shared_ptr<TimingOutline> timingRoot;
201 GTSAM_EXTERN_EXPORT boost::weak_ptr<TimingOutline> timingCurrent;
211 #define gttic_(label) \
212 static const size_t label##_id_tic = ::gtsam::internal::getTicTocID(#label); \
213 ::gtsam::internal::AutoTicToc label##_obj = ::gtsam::internal::AutoTicToc(label##_id_tic, #label)
216 #define gttoc_(label) \
220 #define longtic_(label) \
221 static const size_t label##_id_tic = ::gtsam::internal::getTicTocID(#label); \
222 ::gtsam::internal::ticInternal(label##_id_tic, #label)
225 #define longtoc_(label) \
226 static const size_t label##_id_toc = ::gtsam::internal::getTicTocID(#label); \
227 ::gtsam::internal::tocInternal(label##_id_toc, #label)
230 inline void tictoc_finishedIteration_() {
231 ::gtsam::internal::timingRoot->finishedIteration(); }
234 inline void tictoc_print_() {
235 ::gtsam::internal::timingRoot->print(); }
238 inline void tictoc_print2_() {
239 ::gtsam::internal::timingRoot->print2(); }
242 #define tictoc_getNode(variable, label) \
243 static const size_t label##_id_getnode = ::gtsam::internal::getTicTocID(#label); \
244 const boost::shared_ptr<const ::gtsam::internal::TimingOutline> variable = \
245 ::gtsam::internal::timingCurrent.lock()->child(label##_id_getnode, #label, ::gtsam::internal::timingCurrent);
248 inline void tictoc_reset_() {
249 ::gtsam::internal::timingRoot.reset(new ::gtsam::internal::TimingOutline(
"Total", ::gtsam::internal::getTicTocID(
"Total")));
250 ::gtsam::internal::timingCurrent = ::gtsam::internal::timingRoot; }
253 #define gttic(label) gttic_(label)
254 #define gttoc(label) gttoc_(label)
255 #define longtic(label) longtic_(label)
256 #define longtoc(label) longtoc_(label)
257 #define tictoc_finishedIteration tictoc_finishedIteration_
258 #define tictoc_print tictoc_print_
259 #define tictoc_reset tictoc_reset_
261 #define gttic(label) ((void)0)
262 #define gttoc(label) ((void)0)
263 #define longtic(label) ((void)0)
264 #define longtoc(label) ((void)0)
265 #define tictoc_finishedIteration() ((void)0)
266 #define tictoc_print() ((void)0)
267 #define tictoc_reset() ((void)0)
double t2_
cache the t_i^2
Definition: timing.h:140
double mean() const
mean self time, in seconds
Definition: timing.h:174
No documentation.
Definition: timing.h:189
Included from all GTSAM files.
double max() const
max time, in seconds
Definition: timing.h:173
double min() const
min time, in seconds
Definition: timing.h:172
void print(const Matrix &A, const string &s, ostream &stream)
print a matrix
Definition: Matrix.cpp:183
ChildMap children_
subtrees
Definition: timing.h:152
A thin wrapper around std::map that uses boost's fast_pool_allocator.
boost::weak_ptr< TimingOutline > parent_
parent pointer
Definition: timing.h:150
double wall() const
wall time, in seconds
Definition: timing.h:171
double secs() const
time taken, in seconds, including children
Definition: timing.h:169
Timing Entry, arranged in a tree.
Definition: timing.h:135