#ifndef _PROFILER_H_ #define _PROFILER_H_ #include #include #include #include #include #include "Singleton.h" #ifdef PROFILE class CProfiler : public CSingleton { public: friend CSingleton; class CZone { public: CZone(const char*); void AddTime(clock_t); const char* GetName() const; clock_t GetTime() const; void Reset(); private: std::string m_sName; clock_t m_nTime; }; typedef std::list ZoneList; void BeginIteration(); void EndIteration(); void BeginZone(const char*); void EndZone(); ZoneList GetStats(); void Reset(); private: CProfiler(); virtual ~CProfiler(); CZone& GetCurrentZone(); typedef boost::ptr_map ZoneMap; typedef std::list ZoneStack; boost::mutex m_Mutex; CZone m_OtherZone; clock_t m_nCurrentTime; ZoneMap m_Zones; ZoneStack m_ZoneStack; ZoneList m_Stats; }; #endif #endif