21 std::map<std::string, DebugTimer *> m_timers;
32 std::chrono::high_resolution_clock::duration getDuration()
const {
return m_totalDuration; }
33 int64_t getIterations()
const {
return m_count; }
35 static DebugTimer *getTimer(
const std::string &name);
37 static DebugTimerMap m_timerMap;
42 std::chrono::high_resolution_clock::duration m_totalDuration;
43 std::chrono::time_point<std::chrono::high_resolution_clock> m_startTime;
46 inline DebugTimer::DebugTimer() : m_count(0), m_totalDuration(0)
50 inline DebugTimer::~DebugTimer()
54 inline void DebugTimer::start()
56 m_startTime = std::chrono::high_resolution_clock::now();
59 inline void DebugTimer::stop()
61 auto endTime = std::chrono::high_resolution_clock::now();
62 m_totalDuration += endTime-m_startTime;
66 inline DebugTimer *DebugTimer::getTimer(
const std::string &name)
68 auto it = m_timerMap.m_timers.find(name);
69 DebugTimer *pTimer = 0;
71 if (it == m_timerMap.m_timers.end())
73 pTimer =
new DebugTimer();
74 m_timerMap.m_timers[name] = pTimer;
82 #endif // NODEBUGTIMER
84 #endif // DEBUGTIMER_H