Go to the documentation of this file.
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)
59 virtual const std::string &
getClassName(
void)
const {
return CLASS_NAME; }
62 struct timeval t0, t1;
71 virtual void display(std::ostream &os)
const;
90 template <
bool UseClock>
95 sotDEBUG(15) <<
"t0: " << c0 << std::endl;
97 gettimeofday(&t0, NULL);
98 sotDEBUG(15) <<
"t0: " << t0.tv_sec <<
" - " << t0.tv_usec << std::endl;
105 sotDEBUG(15) <<
"t1: " << c0 << std::endl;
106 dt = ((
double)(c1 - c0) * 1000) / CLOCKS_PER_SEC;
108 gettimeofday(&t1, NULL);
109 dt = ((
static_cast<double>(t1.tv_sec) -
static_cast<double>(t0.tv_sec)) *
111 (
static_cast<double>(t1.tv_usec) -
static_cast<double>(t0.tv_usec) +
114 sotDEBUG(15) <<
"t1: " << t1.tv_sec <<
" - " << t1.tv_usec << std::endl;
118 timerSOUT.setTime(time);
130 void cmdChrono(
const std::string &cmd, std::istringstream &args,
142 sigSIN(NULL,
"Timer(" +
name +
")::input(T)::sin"),
143 sigSOUT(
boost::bind(&
Timer::compute<false>, this, _1, _2), sigSIN,
144 "Timer(" +
name +
")::output(T)::sout"),
145 sigClockSOUT(
boost::bind(&
Timer::compute<true>, this, _1, _2), sigSIN,
146 "Timer(" +
name +
")::output(T)::clockSout"),
147 timerSOUT(
"Timer(" +
name +
")::output(double)::timer") {
158 os <<
"Timer <" << sigSIN <<
"> : " <<
dt <<
"ms." << std::endl;
double & getDt(double &res, const sigtime_t &)
dynamicgraph::SignalPtr< T, dg::sigtime_t > sigSIN
T & compute(T &t, const sigtime_t &time)
dynamicgraph::SignalTimeDependent< T, dg::sigtime_t > sigSOUT
dynamicgraph::sigtime_t sigtime_t
virtual void setFunction(boost::function2< T &, T &, Time > t, Mutex *mutexref=NULL)
static const std::string CLASS_NAME
#define sotDEBUGOUT(level)
Timer_EXPORT friend std::ostream & operator<<(std::ostream &os, const Timer< T > &timer)
Timer(const std::string &name)
void cmdChrono(const std::string &cmd, std::istringstream &args, std::ostream &os)
#define sotDEBUGIN(level)
virtual void display(std::ostream &os) const
dynamicgraph::Signal< double, dg::sigtime_t > timerSOUT
virtual void display(std::ostream &os) const
Signal< dynamicgraph::Matrix, sigtime_t > sig("matrix")
virtual const std::string & getClassName(void) const
void signalRegistration(const SignalArray< sigtime_t > &signals)
dynamicgraph::SignalTimeDependent< T, dg::sigtime_t > sigClockSOUT
void plug(dynamicgraph::Signal< T, dg::sigtime_t > &sig)
sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:32