29 using TimePoint = std::chrono::steady_clock::time_point;
30 template <
typename K,
typename V>
using Map = std::map<K, V>;
45 using namespace std::chrono;
46 return (duration_cast<microseconds>(
t2.time_since_epoch()).count() -
47 duration_cast<microseconds>(
t1.time_since_epoch()).count()) /
60 return std::this_thread::get_id();
64 if (
timers.count(std::this_thread::get_id()) == 0) {
65 timers[std::this_thread::get_id()] = {};
68 if (
timers[std::this_thread::get_id()].count(s) == 0) {
72 return timers[std::this_thread::get_id()][s];
78 assert(!d.started &&
"timer already started");
80 d.t1 = std::chrono::steady_clock::now();
86 assert(d.started &&
"timer already stopped");
88 d.t2 = std::chrono::steady_clock::now();
89 d.duration += d.get_curr_duration_ms();
114 s << endl <<
"Profiler: No statistics generated" << endl;
118 s << endl <<
"Profiler Statistics:" << endl;
121 <<
"'" << k.first <<
"'"
122 <<
": " << k.second << endl;
126 s <<
"Thread " << t.first <<
":" << endl;
128 for (
auto k : t.second) {
130 <<
"'" << k.first <<
"'"
131 <<
": " << k.second.get_cumul_duration_ms() <<
" ms" << endl;
172#ifdef LHF_ENABLE_PERFORMANCE_METRICS
173#define __lhf_calc_time(__stat, __key) \
174 auto __LHF_TIMER_OBJECT__ = __CalcTime((__stat), (__key))
175#define __lhf_calc_functime(__stat) \
176 auto __LHF_TIMER_OBJECT__ = __CalcTime((__stat), __func__)
178#define __lhf_calc_time(__stat, __key)
179#define __lhf_calc_functime(__stat)
Any configurable constants go into this file.
The object used to enable the duration capturing mechanism.
__CalcTime(PerformanceStatistics &stat, const std::string &key)
PerformanceStatistics & stat