All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Timer.h
Go to the documentation of this file.
1 /*
2  * Timer.h
3  *
4  * Created on: 14.01.2013
5  * Author: Christian Staudt (christian.staudt@kit.edu)
6  */
7 
8 #ifndef TIMER_H_
9 #define TIMER_H_
10 
11 #include <chrono>
12 #include <sstream>
13 
14 namespace Aux {
15 
16 #ifdef __MIC__
17 #define my_steady_clock std::chrono::monotonic_clock
18 #else
19 #define my_steady_clock std::chrono::steady_clock
20 #endif
21 
25 class Timer {
26 
27 protected:
28 
29  bool running;
30  my_steady_clock::time_point started;
31  my_steady_clock::time_point stopped;
32 
33 public:
34  Timer();
35 
40  virtual my_steady_clock::time_point start();
41 
46  virtual my_steady_clock::time_point stop();
47 
53  virtual std::chrono::duration<uint64_t, std::milli> elapsed() const;
54 
60  virtual uint64_t elapsedMilliseconds() const;
61 
67  virtual uint64_t elapsedMicroseconds();
68 
74  virtual uint64_t elapsedNanoseconds();
75 
79  virtual my_steady_clock::time_point startTime();
80 
85  virtual my_steady_clock::time_point stopTime();
86 
87 
91  virtual std::string elapsedTag();
92 };
93 
94 } /* namespace Aux */
95 #endif /* TIMER_H_ */
virtual std::chrono::duration< uint64_t, std::milli > elapsed() const
The number of milliseconds since the current time that the Timer object was created.
Definition: Timer.cpp:27
A timer for running time measurements.
Definition: Timer.h:25
bool running
true if timer has been started and not stopped after that
Definition: Timer.h:29
virtual uint64_t elapsedMicroseconds()
The number of microseconds since the current time that the Timer object was created.
Definition: Timer.cpp:47
virtual std::string elapsedTag()
Definition: Timer.cpp:55
virtual uint64_t elapsedNanoseconds()
The number of nanoseconds since the current time that the Timer object was created.
Definition: Timer.cpp:51
my_steady_clock::time_point started
time at which timer has been started
Definition: Timer.h:30
Timer()
Definition: Timer.cpp:12
virtual uint64_t elapsedMilliseconds() const
The number of milliseconds since the current time that the Timer object was created.
Definition: Timer.cpp:43
virtual my_steady_clock::time_point stopTime()
Returns the time at which the instance was stopped.
Definition: Timer.cpp:39
virtual my_steady_clock::time_point stop()
Stops the clock permanently for the instance of the Timer.
Definition: Timer.cpp:21
virtual my_steady_clock::time_point startTime()
Returns the time at which the instance was started.
Definition: Timer.cpp:35
my_steady_clock::time_point stopped
time at which timer has been stopped
Definition: Timer.h:31
virtual my_steady_clock::time_point start()
Start the clock.
Definition: Timer.cpp:15