0.08.01
C++ Open Travel Request Parsing Library
Toggle main menu visibility
Loading...
Searching...
No Matches
BasChronometer.cpp
Go to the documentation of this file.
1
// //////////////////////////////////////////////////////////////////////
2
// Import section
3
// //////////////////////////////////////////////////////////////////////
4
// STL
5
#include <cassert>
6
// OpenTrep
7
#include <
opentrep/basic/BasChronometer.hpp
>
8
#include <
opentrep/service/Logger.hpp
>
9
10
namespace
OPENTREP
{
11
12
// //////////////////////////////////////////////////////////////////////
13
BasChronometer::BasChronometer
() : _startTimeLaunched (false) {
14
}
15
16
// //////////////////////////////////////////////////////////////////////
17
void
BasChronometer::start
() {
18
// Get the time-stamp of now, and store it for later use
19
_startTime = boost::posix_time::microsec_clock::local_time();
20
21
// Update the boolean which states whether the chronometer
22
// is launched
23
_startTimeLaunched =
true
;
24
}
25
26
// //////////////////////////////////////////////////////////////////////
27
double
BasChronometer::elapsed
()
const
{
28
assert (_startTimeLaunched ==
true
);
29
30
// Get the time-stamp of now
31
const
boost::posix_time::ptime lStopTime =
32
boost::posix_time::microsec_clock::local_time();
33
34
// Calculate the time elapsed since the last time-stamp
35
const
boost::posix_time::time_duration lElapsedTime =
36
lStopTime - _startTime;
37
38
// Derived the corresponding number of milliseconds
39
const
double
lElapsedTimeInMicroSeconds =
40
static_cast<
const
double
>
(lElapsedTime.total_microseconds());
41
42
/*OPENTREP_LOG_DEBUG ("Elapsed: " << lElapsedTime
43
<< "; (micros): "
44
<< lElapsedTimeInMicroSeconds / 1e6);*/
45
46
// The elapsed time given in return is expressed in seconds
47
return
(lElapsedTimeInMicroSeconds / 1e6);
48
}
49
50
}
BasChronometer.hpp
Logger.hpp
OPENTREP
Definition
BasChronometer.cpp:10
OPENTREP::BasChronometer::elapsed
double elapsed() const
Definition
BasChronometer.cpp:27
OPENTREP::BasChronometer::BasChronometer
BasChronometer()
Definition
BasChronometer.cpp:13
OPENTREP::BasChronometer::start
void start()
Definition
BasChronometer.cpp:17
Generated on
for OpenTREP by
1.17.0