lintel 0.2.0
Loading...
Searching...
No Matches
StopWatchService.h
Go to the documentation of this file.
1#ifndef LINTEL_STOPWATCHSERVICE_H
2#define LINTEL_STOPWATCHSERVICE_H
3
4#include <chrono>
5#include <ostream>
6
7namespace lintel {
9{
10public:
19 explicit StopWatchService(bool run = true);
20
26 void reset();
27
33 void stop();
34
39 [[nodiscard]] std::chrono::nanoseconds elapsed() const;
40
42 friend std::ostream &operator<<(std::ostream &os, const StopWatchService &service);
43
44private:
45 // start point of timer
46 std::chrono::time_point<std::chrono::steady_clock> m_startTime;
47 std::chrono::time_point<std::chrono::steady_clock> m_endTime;
48 bool m_stopVar = false;
49 bool m_run;
50};
51
52}// namespace lintel
53#endif// LINTEL_STOPWATCHSERVICE_H
Definition StopWatchService.h:9
std::chrono::nanoseconds elapsed() const
Returns the elapsed time of the timer.
void stop()
possibility to stop timer
void reset()
reset timer if started or start timer if it was not started
friend std::ostream & operator<<(std::ostream &os, const StopWatchService &service)
StopWatchService(bool run=true)
constructor for timer. shutdown implies the start or not start of the timer
Definition BaseFeature.h:6
constexpr std::string_view type_name()
Definition TypeName.h:9