NOMAD Source  Version 4.0.0 Beta
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Clock.cpp
Go to the documentation of this file.
1 /**
2  \file Clock.cpp
3  \brief Clock class (implementation)
4  \author Sebastien Le Digabel
5  \date 2010-04-02
6  \see Clock.hpp
7  */
8 #include "Clock.hpp"
9 
10 /*-----------------------------------*/
11 /* static members initialization */
12 /*-----------------------------------*/
13 time_t NOMAD::Clock::_real_t0;
14 clock_t NOMAD::Clock::_CPU_t0 = clock();
15 const double NOMAD::Clock::_D_CLOCKS_PER_SEC = static_cast<double>(CLOCKS_PER_SEC);
16 
17 /*---------------------*/
18 /* Reset the clock */
19 /*---------------------*/
20 void NOMAD::Clock::reset()
21 {
22  time(&_real_t0);
23  _CPU_t0 = clock();
24 }
25 
26 
27 /*---------------------------------------------------------*/
28 /* compute the wall-clock time (real time) elapsed since */
29 /* the construction of the Clock object */
30 /*---------------------------------------------------------*/
31 size_t NOMAD::Clock::getRealTime()
32 {
33  time_t t2;
34  time(&t2);
35  return static_cast<size_t>(difftime(t2, _real_t0));
36 }
Clock class (headers)