7typedef std::chrono::time_point<std::chrono::system_clock> TimePoint;
13 explicit Timer(
const double begin_time);
14 virtual ~Timer() =
default;
16 double elapsed()
const;
21 double _begin_time = 0;
29inline Timer::Timer(
const double begin_time):
30 _begin_time(begin_time)
36inline void Timer::restart()
38 _start = std::chrono::system_clock::now();
41inline double Timer::elapsed()
const
43 return std::chrono::duration<double>(std::chrono::system_clock::now() - _start).count()
47inline std::string format_time_str(
const long int time_in_seconds)
49 std::time_t seconds(time_in_seconds);
53#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
54 gmtime_s(&p, &seconds);
56 gmtime_r(&seconds, &p);
59 const auto days = p.tm_yday;
60 const auto hours = p.tm_hour;
61 const auto mins = p.tm_min;
62 const auto secs = p.tm_sec;
65 ss << days <<
" days ";
69 ss << hours <<
" hours ";
73 ss << mins <<
" minutes ";
77 ss << secs <<
" seconds ";