Chi-Tech
chi_timer.h
Go to the documentation of this file.
1#ifndef CHI_TIMER_H
2#define CHI_TIMER_H
3
4#include <string>
5#include <chrono>
6
7
8//################################################################### CLASS DEF
9namespace chi
10{
11 /** Timer object.*/
12 class Timer
13{
14 private:
15 std::chrono::steady_clock::time_point start_time_;
16
17 public:
18 //00
19 Timer() noexcept;
20 //01
21 void Reset();
22 double GetTime() const;
23 std::string GetTimeString() const;
24 static std::string GetLocalDateTimeString();
25 };
26
27 /**Puts the current thread to sleep.
28 * \param time Time to sleep for.
29 *
30 * \note To specify different times `std::chrono` allows
31 * you to change the unit with, e.g.,
32 * `chi::Sleep(std::chrono::milliseconds(100))` sleeps for 100 milliseconds,
33 * `std::Sleep(std::chrono::seconds(1))` sleeps for 1 second.*/
34 void Sleep(std::chrono::duration<double> time);
35}
36
37#endif
38
void Reset()
Definition: chi_timer.cc:16
double GetTime() const
Definition: chi_timer.cc:23
static std::string GetLocalDateTimeString()
Definition: chi_timer.cc:55
std::string GetTimeString() const
Definition: chi_timer.cc:38
Timer() noexcept
Definition: chi_timer.cc:9
std::chrono::steady_clock::time_point start_time_
Definition: chi_timer.h:15
void Sleep(std::chrono::duration< double > time)
Definition: chi_timer.cc:68