25 using TimePoint = std::chrono::steady_clock::time_point;
26 template <
typename K,
typename V>
using Map = std::map<K, V>;
35 return (std::chrono::duration_cast<std::chrono::microseconds>(
t2.time_since_epoch())
37 std::chrono::duration_cast<std::chrono::microseconds>(
t1.time_since_epoch())
51 if (
timers.count(s) == 0) {
60 assert(!d.started &&
"timer already started");
62 d.t1 = std::chrono::steady_clock::now();
67 assert(d.started &&
"timer already stopped");
69 d.t2 = std::chrono::steady_clock::now();
70 d.duration += d.get_curr_duration_ms();
92 s << endl <<
"Profiler: No statistics generated" << endl;
96 s << endl <<
"Profiler Statistics:" << endl;
99 <<
"'" << k.first <<
"'"
100 <<
": " << k.second << endl;
104 <<
"'" << k.first <<
"'"
105 <<
": " << k.second.get_cumul_duration_ms() <<
" ms" << endl;
142#ifdef LHF_ENABLE_PERFORMANCE_METRICS
143#define __lhf_calc_time(__stat, __key) \
144 auto __LHF_TIMER_OBJECT__ = __CalcTime((__stat), (__key))
145#define __lhf_calc_functime(__stat) \
146 auto __LHF_TIMER_OBJECT__ = __CalcTime((__stat), __func__)
148#define __lhf_calc_time(__stat, __key)
149#define __lhf_calc_functime(__stat)
The object used to enable the duration capturing mechanism.
__CalcTime(PerformanceStatistics &stat, const std::string key)
PerformanceStatistics & stat