timer.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 /* --------------------------------------------------------------------- */
11 /* --- INCLUDE --------------------------------------------------------- */
12 /* --------------------------------------------------------------------- */
13 
14 /* SOT */
16 
17 #include <sot/core/factory.hh>
19 #include <sot/core/timer.hh>
20 
21 using namespace dynamicgraph::sot;
22 using namespace dynamicgraph;
23 
24 /* --------------------------------------------------------------------- */
25 /* --- CLASS ----------------------------------------------------------- */
26 /* --------------------------------------------------------------------- */
27 
29 template <>
31 
33 template <>
35 
37 template <>
39 
41 template <>
43 
44 /* --------------------------------------------------------------------- */
45 void cmdChrono(const std::string &cmdLine, std::istringstream &cmdArg,
46  std::ostream &os) {
47  sotDEBUGIN(15);
48 
49  if (cmdLine == "help") {
50  os << " - chrono <cmd...>"
51  << "\t\t\t\tLaunch <cmd> and display the time spent in the operation."
52  << std::endl;
53  return;
54  }
55 
56  struct timeval t0, t1;
57  double dt;
58 
59  gettimeofday(&t0, NULL);
60  sotDEBUG(15) << "t0: " << t0.tv_sec << " - " << t0.tv_usec << std::endl;
61 
62  std::string cmdLine2;
63  cmdArg >> cmdLine2;
64  sotDEBUG(5) << "Chrono <" << cmdLine2 << ">" << std::endl;
65  // Florent: remove reference to g_shell
66  // g_shell.cmd(cmdLine2,cmdArg,os);
67 
68  gettimeofday(&t1, NULL);
69  dt = ((static_cast<double>(t1.tv_sec) - static_cast<double>(t0.tv_sec)) *
70  1000. +
71  (static_cast<double>(t1.tv_usec) - static_cast<double>(t0.tv_usec) +
72  0.) /
73  1000.);
74  sotDEBUG(15) << "t1: " << t1.tv_sec << " - " << t1.tv_usec << std::endl;
75 
76  os << "Time spent = " << dt << " ms " << std::endl;
77 
78  sotDEBUGOUT(15);
79 }
80 
81 /* --------------------------------------------------------------------- */
82 /* --- CONTROL --------------------------------------------------------- */
83 /* --------------------------------------------------------------------- */
Timer< dynamicgraph::Matrix > timematrix
Definition: timer.cpp:32
#define sotDEBUGOUT(level)
Definition: debug.hh:212
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(FeaturePosture, "FeaturePosture")
#define sotDEBUGIN(level)
Definition: debug.hh:211
void cmdChrono(const std::string &cmdLine, std::istringstream &cmdArg, std::ostream &os)
Definition: timer.cpp:45
Timer< dynamicgraph::Vector > timevect
Definition: timer.cpp:28
Timer< double > timedouble
Definition: timer.cpp:40
#define sotDEBUG(level)
Definition: debug.hh:165
Timer< MatrixHomogeneous > timematrixhomo
Definition: timer.cpp:36
Definition: timer.hh:54


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26