Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Timer.hpp
Go to the documentation of this file.
1 // Timer.hpp
3 // =======
4 // High Resolution Timer.
5 // This timer is able to measure the elapsed time with 1 micro-second accuracy
6 // in both Windows, Linux and Unix system
7 //
8 // AUTHOR: Song Ho Ahn ([email protected])
9 // CREATED: 2003-01-13
10 // UPDATED: 2006-01-13
11 //
12 // Copyright (c) 2003 Song Ho Ahn
14 
15 #ifndef OPENTXS_CORE_TIMER_HPP
16 #define OPENTXS_CORE_TIMER_HPP
17 
18 #include <cinttypes>
19 
20 #ifdef _WIN32
21 #ifndef _WINDOWS_
22 #ifndef WIN32_LEAN_AND_MEAN
23 #define WIN32_LEAN_AND_MEAN
24 #endif
25 #include <windows.h>
26 #endif
27 #else
28 #include <sys/time.h>
29 #endif
30 
31 class Timer
32 {
33 public:
34  EXPORT Timer(bool bStart = false); // default constructor // FT: added
35  // default argument.
36  EXPORT ~Timer(); // default destructor
37 
38  EXPORT void start(); // start timer
39  void stop(); // stop the timer
40  void clear(); // stop the timer and clear the contents.
41 
42  double getElapsedTime(); // get elapsed time in second
43  double getElapsedTimeInSec(); // get elapsed time in second (same as
44  // getElapsedTime)
45  EXPORT double getElapsedTimeInMilliSec(); // get elapsed time in
46  // milli-second
47  double getElapsedTimeInMicroSec(); // get elapsed time in micro-second
48 
49 protected:
50 private:
51  double startTimeInMicroSec; // starting time in micro-second
52  double endTimeInMicroSec; // ending time in micro-second
53  int32_t stopped; // stop flag
54 #ifdef WIN32
55  LARGE_INTEGER frequency; // ticks per second
56  LARGE_INTEGER startCount; //
57  LARGE_INTEGER endCount; //
58 #else
59  timeval startCount; //
60  timeval endCount; //
61 #endif
62 };
63 
64 #endif // OPENTXS_CORE_TIMER_HPP
Definition: Timer.hpp:31
EXPORT double getElapsedTimeInMilliSec()
Definition: Timer.cpp:111
void stop()
Definition: Timer.cpp:55
EXPORT void start()
Definition: Timer.cpp:41
double getElapsedTime()
Definition: Timer.cpp:127
void clear()
Definition: Timer.cpp:69
double getElapsedTimeInMicroSec()
Definition: Timer.cpp:90
EXPORT Timer(bool bStart=false)
Definition: Timer.cpp:21
double getElapsedTimeInSec()
Definition: Timer.cpp:119
EXPORT ~Timer()
Definition: Timer.cpp:33