GCC Code Coverage Report


Directory: ./
File: src/tools/timer.cpp
Date: 2024-12-13 12:22:33
Exec Total Coverage
Lines: 0 17 0.0%
Branches: 0 26 0.0%

Line Branch Exec Source
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 */
15 #include <dynamic-graph/linear-algebra.h>
16
17 #include <sot/core/factory.hh>
18 #include <sot/core/matrix-geometry.hh>
19 #include <sot/core/timer.hh>
20
21 using namespace dynamicgraph::sot;
22 using namespace dynamicgraph;
23
24 /* --------------------------------------------------------------------- */
25 /* --- CLASS ----------------------------------------------------------- */
26 /* --------------------------------------------------------------------- */
27
28 typedef Timer<dynamicgraph::Vector> timevect;
29 template <>
30 DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(timevect, "TimerVector");
31
32 typedef Timer<dynamicgraph::Matrix> timematrix;
33 template <>
34 DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(timematrix, "TimerMatrix");
35
36 typedef Timer<MatrixHomogeneous> timematrixhomo;
37 template <>
38 DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(timematrixhomo, "TimerMatrixHomo");
39
40 typedef Timer<double> timedouble;
41 template <>
42 DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(timedouble, "TimerDouble");
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 /* --------------------------------------------------------------------- */
84