-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTimer.hpp
51 lines (44 loc) · 1.1 KB
/
Timer.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Timer.hpp
*
* Created on: 21-Sep-2019
* Author: Prashant Srivastava
*/
#ifndef TIMER_HPP_
#define TIMER_HPP_
#include <chrono>
#include <string>
/**
* @class Timer
* @brief A class responsible for knowing time elapsed between two events
*/
class Timer {
public:
/**
* @brief Constructor
* @param [in] fmtString The format in which message needs to be displayed
* after end of a event.
*/
Timer(const char *fmtString);
/**
* @brief Default Destructor
*/
virtual ~Timer();
/**
* @brief Method to show the elapsed time
* @param [in] resetStartTime Wether to reset the timer after show
* <i>optional</i>.
*/
void show(bool resetStartTime = true);
/**
* @brief Overloaded parenthesis operator to return the elapsed time.
*/
operator double();
private:
std::chrono::steady_clock::time_point
startTime; ///< The start time captured at start of event
std::chrono::steady_clock::time_point
endTime; ///< The end time captured at end of event
const char *fmtString;
};
#endif /* TIMER_HPP_ */