Using boost timer instead of chrono to support older boost versions
parent
1b5b4d494e
commit
dacff98f9f
|
@ -20,7 +20,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
@ -48,7 +47,7 @@ void TimingOutline::add(size_t usecs) {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TimingOutline::TimingOutline(const std::string& label) :
|
TimingOutline::TimingOutline(const std::string& label) :
|
||||||
t_(0), t2_(0.0), tIt_(0), tMax_(0), tMin_(0), n_(0), label_(label), timerActive_(false) {}
|
t_(0), t2_(0.0), tIt_(0), tMax_(0), tMin_(0), n_(0), label_(label) {}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
size_t TimingOutline::time() const {
|
size_t TimingOutline::time() const {
|
||||||
|
@ -151,18 +150,15 @@ const boost::shared_ptr<TimingOutline>& TimingOutline::child(size_t child, const
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void TimingOutline::tic() {
|
void TimingOutline::tic() {
|
||||||
assert(!timerActive_);
|
assert(timer_.is_stopped());
|
||||||
timerActive_ = true;
|
timer_.start();
|
||||||
gettimeofday(&t0_, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void TimingOutline::toc() {
|
void TimingOutline::toc() {
|
||||||
struct timeval t;
|
assert(!timer_.is_stopped());
|
||||||
gettimeofday(&t, NULL);
|
timer_.stop();
|
||||||
assert(timerActive_);
|
add((timer_.elapsed().user + timer_.elapsed().system) / 1000);
|
||||||
add(t.tv_sec*1000000 + t.tv_usec - (t0_.tv_sec*1000000 + t0_.tv_usec));
|
|
||||||
timerActive_ = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
@ -231,6 +227,8 @@ void toc_(size_t id, const std::string& label) {
|
||||||
toc_(id);
|
toc_(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_OLD_TIMING
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
// Timing class implementation
|
// Timing class implementation
|
||||||
void Timing::print() {
|
void Timing::print() {
|
||||||
|
@ -260,3 +258,5 @@ void ticPop_(const std::string& prefix, const std::string& id) {
|
||||||
else
|
else
|
||||||
timingPrefix.resize(timingPrefix.size() - prefix.size() - 1);
|
timingPrefix.resize(timingPrefix.size() - prefix.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -22,6 +22,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/weak_ptr.hpp>
|
#include <boost/weak_ptr.hpp>
|
||||||
|
#include <boost/timer/timer.hpp>
|
||||||
|
|
||||||
class TimingOutline;
|
class TimingOutline;
|
||||||
extern boost::shared_ptr<TimingOutline> timingRoot;
|
extern boost::shared_ptr<TimingOutline> timingRoot;
|
||||||
|
@ -39,8 +40,7 @@ protected:
|
||||||
|
|
||||||
boost::weak_ptr<TimingOutline> parent_;
|
boost::weak_ptr<TimingOutline> parent_;
|
||||||
std::vector<boost::shared_ptr<TimingOutline> > children_;
|
std::vector<boost::shared_ptr<TimingOutline> > children_;
|
||||||
struct timeval t0_;
|
boost::timer::cpu_timer timer_;
|
||||||
bool timerActive_;
|
|
||||||
|
|
||||||
void add(size_t usecs);
|
void add(size_t usecs);
|
||||||
|
|
||||||
|
@ -89,6 +89,18 @@ inline void toc(size_t, const char*) {}
|
||||||
inline void tictoc_finishedIteration() {}
|
inline void tictoc_finishedIteration() {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
inline void tictoc_print_() {
|
||||||
|
timingRoot->print();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* print mean and standard deviation */
|
||||||
|
inline void tictoc_print2_() {
|
||||||
|
timingRoot->print2();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_OLD_TIMING
|
||||||
|
|
||||||
// simple class for accumulating execution timing information by name
|
// simple class for accumulating execution timing information by name
|
||||||
class Timing;
|
class Timing;
|
||||||
extern Timing timing;
|
extern Timing timing;
|
||||||
|
@ -100,7 +112,6 @@ double tic(const std::string& id);
|
||||||
double toc(const std::string& id);
|
double toc(const std::string& id);
|
||||||
void ticPush(const std::string& id);
|
void ticPush(const std::string& id);
|
||||||
void ticPop(const std::string& id);
|
void ticPop(const std::string& id);
|
||||||
void tictoc_print();
|
|
||||||
void tictoc_finishedIteration();
|
void tictoc_finishedIteration();
|
||||||
|
|
||||||
/** These underscore versions work evening when ENABLE_TIMING is not defined */
|
/** These underscore versions work evening when ENABLE_TIMING is not defined */
|
||||||
|
@ -110,7 +121,6 @@ double tic_(const std::string& id);
|
||||||
double toc_(const std::string& id);
|
double toc_(const std::string& id);
|
||||||
void ticPush_(const std::string& id);
|
void ticPush_(const std::string& id);
|
||||||
void ticPop_(const std::string& id);
|
void ticPop_(const std::string& id);
|
||||||
void tictoc_print_();
|
|
||||||
void tictoc_finishedIteration_();
|
void tictoc_finishedIteration_();
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,16 +183,6 @@ inline void ticPush_(const std::string& prefix, const std::string& id) {
|
||||||
}
|
}
|
||||||
void ticPop_(const std::string& prefix, const std::string& id);
|
void ticPop_(const std::string& prefix, const std::string& id);
|
||||||
|
|
||||||
inline void tictoc_print_() {
|
|
||||||
timing.print();
|
|
||||||
timingRoot->print();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* print mean and standard deviation */
|
|
||||||
inline void tictoc_print2_() {
|
|
||||||
timingRoot->print2();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_TIMING
|
#ifdef ENABLE_TIMING
|
||||||
inline double _tic() { return _tic_(); }
|
inline double _tic() { return _tic_(); }
|
||||||
inline double _toc(double t) { return _toc_(t); }
|
inline double _toc(double t) { return _toc_(t); }
|
||||||
|
@ -200,3 +200,5 @@ inline void ticPush(const std::string&, const std::string&) {}
|
||||||
inline void ticPop(const std::string&, const std::string&) {}
|
inline void ticPop(const std::string&, const std::string&) {}
|
||||||
inline void tictoc_print() {}
|
inline void tictoc_print() {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -140,19 +140,13 @@ SharedDiagonal Gaussian::Cholesky(Matrix& Ab, size_t nFrontals) const {
|
||||||
// TODO: really no rank problems ?
|
// TODO: really no rank problems ?
|
||||||
|
|
||||||
// pre-whiten everything (cheaply if possible)
|
// pre-whiten everything (cheaply if possible)
|
||||||
tic("Cholesky: 1 whiten");
|
|
||||||
WhitenInPlace(Ab);
|
WhitenInPlace(Ab);
|
||||||
toc("Cholesky: 1 whiten");
|
|
||||||
|
|
||||||
// Form A'*A (todo: this is probably less efficient than possible)
|
// Form A'*A (todo: this is probably less efficient than possible)
|
||||||
tic("Cholesky: 2 A' * A");
|
|
||||||
Ab = Ab.transpose() * Ab;
|
Ab = Ab.transpose() * Ab;
|
||||||
toc("Cholesky: 2 A' * A");
|
|
||||||
|
|
||||||
// Use Cholesky to factor Ab
|
// Use Cholesky to factor Ab
|
||||||
tic("Cholesky: 3 careful");
|
|
||||||
size_t maxrank = choleskyCareful(Ab).first;
|
size_t maxrank = choleskyCareful(Ab).first;
|
||||||
toc("Cholesky: 3 careful");
|
|
||||||
|
|
||||||
// Due to numerical error the rank could appear to be more than the number
|
// Due to numerical error the rank could appear to be more than the number
|
||||||
// of variables. The important part is that it does not includes the
|
// of variables. The important part is that it does not includes the
|
||||||
|
|
Loading…
Reference in New Issue