123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- #ifndef __SUPPORT_CCPROFILING_H__
- #define __SUPPORT_CCPROFILING_H__
- #include <string>
- #include <chrono>
- #include "base/ccConfig.h"
- #include "base/CCRef.h"
- #include "base/CCMap.h"
- NS_CC_BEGIN
- class ProfilingTimer;
- class CC_DLL Profiler : public Ref
- {
- public:
-
- ~Profiler(void);
-
- void displayTimers(void);
-
- bool init(void);
- public:
-
- static Profiler* getInstance(void);
-
- CC_DEPRECATED_ATTRIBUTE static Profiler* sharedProfiler(void);
-
- ProfilingTimer* createAndAddTimerWithName(const char* timerName);
-
- void releaseTimer(const char* timerName);
-
- void releaseAllTimers();
- Map<std::string, ProfilingTimer*> _activeTimers;
- };
- class ProfilingTimer : public Ref
- {
- public:
-
- ProfilingTimer();
-
- ~ProfilingTimer(void);
-
- bool initWithName(const char* timerName);
-
- virtual std::string getDescription() const;
-
- const std::chrono::high_resolution_clock::time_point& getStartTime() { return _startTime; }
-
- void reset();
- std::string _nameStr;
- std::chrono::high_resolution_clock::time_point _startTime;
- long _averageTime1;
- long _averageTime2;
- long minTime;
- long maxTime;
- long totalTime;
- long numberOfCalls;
- };
- extern void CC_DLL ProfilingBeginTimingBlock(const char *timerName);
- extern void CC_DLL ProfilingEndTimingBlock(const char *timerName);
- extern void CC_DLL ProfilingResetTimingBlock(const char *timerName);
- extern bool kProfilerCategorySprite;
- extern bool kProfilerCategoryBatchSprite;
- extern bool kProfilerCategoryParticles;
- NS_CC_END
- #endif
|