23 #include <type_traits>
29 template <
typename TimeT = std::chrono::milliseconds>
31 template <
typename F,
typename... Args>
33 auto start = std::chrono::steady_clock::now();
34 func(std::forward<Args>(
args)...);
36 std::chrono::duration_cast<TimeT>(std::chrono::steady_clock::now() - start);
37 return duration.count();
41 template <
typename Type = std::chrono::steady_clock::time_po
int>
43 return std::chrono::steady_clock::now();
46 template <
typename Type = std::chrono::steady_clock::time_point,
47 typename TypeR = std::chrono::milliseconds>
50 std::chrono::duration_cast<TypeR>(std::chrono::steady_clock::now() - clock_begin);
51 return duration.count();
55 timer_stop<std::chrono::steady_clock::time_point, std::chrono::microseconds>;
57 template <
typename Type = std::chrono::steady_clock::time_point,
58 typename TypeR = std::chrono::milliseconds>
60 auto now = std::chrono::steady_clock::now();
61 auto overall_duration = (now - clock_begin);
62 auto since_last_duration = (now - clock_last);
63 auto overall = std::chrono::duration_cast<TypeR>(overall_duration);
64 auto since_last = std::chrono::duration_cast<TypeR>(since_last_duration);
67 std::ostringstream oss;
68 oss << overall.count() <<
" - " << since_last.count();
73 InjectTimer(std::string
const& description,
int const& lineNum, std::string
const& func)
78 <<
" " << std::setw(35) <<
func_ <<
":" << std::setw(5) <<
lineNum_;
85 <<
" " << std::setw(35) <<
func_ <<
":" << std::setw(5) <<
lineNum_
94 std::chrono::steady_clock::time_point
start_;
96 #define INJECT_TIMER(DESC) InjectTimer DESC(#DESC, __LINE__, __FUNCTION__)
98 template <
typename Fn, Fn fn,
typename... Args>
101 return fn(std::forward<Args>(
args)...);
103 #define TIME_WRAP(FUNC) time_wrap<decltype(&FUNC), &FUNC>
105 #endif // _MEASURE_H_
std::chrono::steady_clock::time_point start_
static TimeT::rep execution(F func, Args &&...args)
bool g_enable_debug_timer
TypeR::rep timer_stop(Type clock_begin)
std::string timer_lap(Type clock_begin, Type &clock_last)
const auto timer_stop_microseconds
InjectTimer(std::string const &description, int const &lineNum, std::string const &func)
std::result_of< Fn(Args...)>::type time_wrap(Args...args)