8typedef 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;
24inline Timer::Timer() { restart(); }
25inline Timer::Timer(
const double begin_time) : _begin_time(begin_time) {
30inline void Timer::restart() { _start = std::chrono::system_clock::now(); }
32inline double Timer::elapsed()
const {
33 return std::chrono::duration<double>(std::chrono::system_clock::now() -
39inline std::string format_time_str(
const long int time_in_seconds) {
45#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
46 gmtime_s(&p, &seconds);
48 gmtime_r(&seconds, &p);
51 const auto days = p.tm_yday;
52 const auto hours = p.tm_hour;
53 const auto mins = p.tm_min;
54 const auto secs = p.tm_sec;
56 ss << days <<
" days ";
59 ss << hours <<
" hours ";
62 ss << mins <<
" minutes ";
65 ss << secs <<
" seconds ";