#ifndef __SUPPORT_CCPROFILING_H__
#define __SUPPORT_CCPROFILING_H__
#include "ccConfig.h"
#include "cocoa/CCObject.h"
#include "platform/platform.h"
#include "cocoa/CCDictionary.h"
#include <string>
NS_CC_BEGIN
/**
* @addtogroup global
* @{
*/
class CCProfilingTimer;
/** CCProfiler
cocos2d builtin profiler.
To use it, enable set the CC_ENABLE_PROFILERS=1 in the ccConfig.h file
*/
class CC_DLL CCProfiler : public CCObject
{
public:
~CCProfiler(void);
/** display the timers */
void displayTimers(void);
bool init(void);
public:
static CCProfiler* sharedProfiler(void);
/** Creates and adds a new timer */
CCProfilingTimer* createAndAddTimerWithName(const char* timerName);
/** releases a timer */
void releaseTimer(const char* timerName);
/** releases all timers */
void releaseAllTimers();
CCDictionary* m_pActiveTimers;
};
class CCProfilingTimer : public CCObject
{
public:
bool initWithName(const char* timerName);
~CCProfilingTimer(void);
const char* description(void);
inline struct cc_timeval * getStartTime(void) { return &m_sStartTime; };
inline void setAverageTime(double value) { m_dAverageTime = value; }
inline double getAverageTime(void) { return m_dAverageTime; }
/** resets the timer properties */
void reset();
std::string m_NameStr;
struct cc_timeval m_sStartTime;
double m_dAverageTime;
double minTime;
double maxTime;
double totalTime;
unsigned int numberOfCalls;
};
extern void CCProfilingBeginTimingBlock(const char *timerName);
extern void CCProfilingEndTimingBlock(const char *timerName);
extern void CCProfilingResetTimingBlock(const char *timerName);
/*
* cocos2d profiling categories
* used to enable / disable profilers with granularity
*/
extern bool kCCProfilerCategorySprite;
extern bool kCCProfilerCategoryBatchSprite;
extern bool kCCProfilerCategoryParticles;
// end of global group
/// @}
NS_CC_END
#endif // __SUPPORT_CCPROFILING_H__