27 using TimePoint = std::chrono::steady_clock::time_point;
28 template <
typename K,
typename V>
using Map = std::map<K, V>;
43 using namespace std::chrono;
58 return std::this_thread::get_id();
62 if (
timers.count(std::this_thread::get_id()) == 0) {
63 timers[std::this_thread::get_id()] = {};
70 return timers[std::this_thread::get_id()][
s];
76 assert(!
d.started &&
"timer already started");
78 d.t1 = std::chrono::steady_clock::now();
84 assert(
d.started &&
"timer already stopped");
86 d.t2 = std::chrono::steady_clock::now();
87 d.duration +=
d.get_curr_duration_ms();
112 s <<
endl <<
"Profiler: No statistics generated" <<
endl;
116 s <<
endl <<
"Profiler Statistics:" <<
endl;
119 <<
"'" <<
k.first <<
"'"
120 <<
": " <<
k.second <<
endl;
124 s <<
"Thread " <<
t.first <<
":" <<
endl;
126 for (
auto k :
t.second) {
128 <<
"'" <<
k.first <<
"'"
129 <<
": " <<
k.second.get_cumul_duration_ms() <<
" ms" <<
endl;
170#ifdef MDE_ENABLE_PERFORMANCE_METRICS
171#define __mde_calc_time(__stat, __key) \
172 auto __MDE_TIMER_OBJECT__ = __CalcTime((__stat), (__key))
173#define __mde_calc_functime(__stat) \
174 auto __MDE_TIMER_OBJECT__ = __CalcTime((__stat), __func__)
176#define __mde_calc_time(__stat, __key)
177#define __mde_calc_functime(__stat)
std::hash< T > DefaultHash
The object used to enable the duration capturing mechanism.
PerformanceStatistics & stat
__CalcTime(PerformanceStatistics &stat, const std::string &key)