6 #ifndef UTILS_UTL_CHRONO_H_
7 #define UTILS_UTL_CHRONO_H_
16 template <
typename TimeT = std::chrono::milliseconds>
18 template <
typename F,
typename... Args>
19 static typename TimeT::rep execution(F&& func, Args&&... args) {
20 auto start = std::chrono::system_clock::now();
21 std::forward<decltype(func)>(func)(std::forward<Args>(args)...);
22 auto duration = std::chrono::duration_cast<TimeT>(std::chrono::system_clock::now() - start);
23 return duration.count();
26 static void start(
void) { start_time_ = std::chrono::system_clock::now(); }
28 static typename TimeT::rep stop(
void) {
29 auto duration = std::chrono::duration_cast<TimeT>(std::chrono::system_clock::now() - start_time_);
30 return duration.count();
33 static std::chrono::system_clock::time_point start_time_;
36 template <
typename TimeT>
43 #endif // UTILS_UTL_CHRONO_H_