10 #ifndef __SOT_TIMER_HH 11 #define __SOT_TIMER_HH 31 #include <dynamic-graph/entity.h> 40 #if defined(timer_EXPORTS) 41 #define Timer_EXPORT __declspec(dllexport) 43 #define Timer_EXPORT __declspec(dllimport) 57 virtual const std::string &
getClassName(
void)
const {
return CLASS_NAME; }
60 struct timeval t0, t1;
69 virtual void display(std::ostream &os)
const;
88 template <
bool UseClock>
93 sotDEBUG(15) <<
"t0: " << c0 << std::endl;
95 gettimeofday(&t0, NULL);
96 sotDEBUG(15) <<
"t0: " << t0.tv_sec <<
" - " << t0.tv_usec << std::endl;
103 sotDEBUG(15) <<
"t1: " << c0 << std::endl;
104 dt = ((
double)(c1 - c0) * 1000) / CLOCKS_PER_SEC;
106 gettimeofday(&t1, NULL);
107 dt = ((
static_cast<double>(t1.tv_sec) - static_cast<double>(t0.tv_sec)) *
109 (static_cast<double>(t1.tv_usec) -
static_cast<double>(t0.tv_usec) +
112 sotDEBUG(15) <<
"t1: " << t1.tv_sec <<
" - " << t1.tv_usec << std::endl;
122 double &
getDt(
double &res,
const int & ) {
128 void cmdChrono(
const std::string &cmd, std::istringstream &
args,
140 sigSIN(NULL,
"Timer(" + name +
")::input(T)::sin"),
141 sigSOUT(
boost::bind(&
Timer::compute<false>, this, _1, _2), sigSIN,
142 "Timer(" + name +
")::output(T)::sout"),
143 sigClockSOUT(
boost::bind(&
Timer::compute<true>, this, _1, _2), sigSIN,
144 "Timer(" + name +
")::output(T)::clockSout"),
145 timerSOUT(
"Timer(" + name +
")::output(double)::timer") {
156 os <<
"Timer <" <<
sigSIN <<
"> : " <<
dt <<
"ms." << std::endl;
dynamicgraph::SignalTimeDependent< T, int > sigClockSOUT
dynamicgraph::SignalPtr< T, int > sigSIN
void signalRegistration(const SignalArray< int > &signals)
double & getDt(double &res, const int &)
#define sotDEBUGOUT(level)
Signal< dynamicgraph::Matrix, int > sig("matrix")
static const std::string CLASS_NAME
#define sotDEBUGIN(level)
Timer_EXPORT friend std::ostream & operator<<(std::ostream &os, const Timer< T > &timer)
Timer(const std::string &name)
virtual void display(std::ostream &os) const
virtual void display(std::ostream &os) const
dynamicgraph::SignalTimeDependent< T, int > sigSOUT
dynamicgraph::Signal< double, int > timerSOUT
virtual const std::string & getClassName(void) const
void plug(dynamicgraph::Signal< T, int > &sig)
virtual void setTime(const Time &t)
T & compute(T &t, const int &time)
virtual void setFunction(boost::function2< T &, T &, Time > t, Mutex *mutexref=NULL)
void cmdChrono(const std::string &cmd, std::istringstream &args, std::ostream &os)