19 std::map<std::string, DebugTimer *> m_timers;
30 std::chrono::high_resolution_clock::duration getDuration()
const {
return m_totalDuration; }
31 int64_t getIterations()
const {
return m_count; }
33 static DebugTimer *getTimer(
const std::string &name);
35 static DebugTimerMap m_timerMap;
40 std::chrono::high_resolution_clock::duration m_totalDuration;
41 std::chrono::time_point<std::chrono::high_resolution_clock> m_startTime;
44 inline DebugTimer::DebugTimer() : m_count(0), m_totalDuration(0)
48 inline DebugTimer::~DebugTimer()
52 inline void DebugTimer::start()
54 m_startTime = std::chrono::high_resolution_clock::now();
57 inline void DebugTimer::stop()
59 auto endTime = std::chrono::high_resolution_clock::now();
60 m_totalDuration += endTime-m_startTime;
64 inline DebugTimer *DebugTimer::getTimer(
const std::string &name)
66 auto it = m_timerMap.m_timers.find(name);
67 DebugTimer *pTimer = 0;
69 if (it == m_timerMap.m_timers.end())
71 pTimer =
new DebugTimer();
72 m_timerMap.m_timers[name] = pTimer;
80 #endif // DEBUGTIMER_H