00001 #ifndef _PROFILER_H_ 00002 #define _PROFILER_H_ 00003 00004 #include <string> 00005 #include "SDL.h" 00006 #include "DebugUtil.h" 00007 00008 class Profiler 00009 { 00010 public: 00011 Profiler(std::string name = "Generic Profile") : m_name(name), m_startTime(0), m_endTime(0) {} 00012 ~Profiler() {} 00013 00014 void Start() { m_startTime = SDL_GetTicks(); } 00015 void End() { m_endTime = SDL_GetTicks(); } 00016 00017 void PrintResults() 00018 { 00019 if(m_endTime != 0) 00020 { 00021 DebugUtil::outputDebugText("Profile results for \"%s\":\n", m_name.c_str()); 00022 unsigned int totalTime = m_endTime - m_startTime; 00023 DebugUtil::outputDebugText("Total time: %d\n", totalTime); 00024 } 00025 } 00026 00027 protected: 00028 std::string m_name; 00029 unsigned int m_startTime, m_endTime; 00030 }; 00031 00032 #endif
1.5.9