afProfiler.h
资源名称:AirForce.rar [点击查看]
上传用户:kaiguan
上传日期:2007-10-28
资源大小:1074k
文件大小:1k
源码类别:
其他游戏
开发平台:
Visual C++
- #ifndef AF_PROFILE
- #define AF_PROFILE
- #include "afList.h"
- #include "afString.h"
- #include <windows.h>
- /// afProfiler provides precise profiling methods
- /**
- * afProfiler uses the processors VERY HIGH PRECISSION
- * timer functions, which are precise enough to bench
- * even single assembler commands...
- */
- class afProfiler
- {
- public:
- afProfiler(const char* nName);
- ~afProfiler();
- void beginSection();
- void endSection();
- static void logResult();
- protected:
- static bool globalBegin();
- static bool globalEnd();
- int listIndex;
- LARGE_INTEGER beginTime;
- struct ProfileInfo
- {
- public:
- afString name;
- LARGE_INTEGER time;
- };
- friend bool operator==(const ProfileInfo&, const ProfileInfo&)
- { return false; }
- static afList<ProfileInfo> timerList;
- static LARGE_INTEGER globalBeginTime;
- };
- inline void afProfiler::beginSection()
- {
- QueryPerformanceCounter(&beginTime);
- }
- inline void
- afProfiler::endSection()
- {
- LARGE_INTEGER& time = timerList.getAt(listIndex).time;
- LARGE_INTEGER tmpTime;
- QueryPerformanceCounter(&tmpTime);
- time.QuadPart += tmpTime.QuadPart - beginTime.QuadPart;
- }
- #endif