本文来自http://blog.csdn.net/runaying ,引用必须注明出处!
cocos2d-x节点(CCProfiling.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
cocos2d内置分析器
///cocos2d-x-3.0alpha0/cocos2dx/support
//cocos2d内置分析器
#ifndef __SUPPORT_CCPROFILING_H__
#define __SUPPORT_CCPROFILING_H__
#include <string>
#include <chrono>
#include "ccConfig.h"
#include "cocoa/CCObject.h"
#include "cocoa/CCDictionary.h"
NS_CC_BEGIN
/**
* @addtogroup global
* @{
*/
class ProfilingTimer;
/** 探查cocos2d内置分析器。
为了使用它要启用 ccConfig.h 文件里面的 CC_ENABLE_PROFILERS=1
*/
class CC_DLL Profiler : public Object
{
public:
/**
* @js NA
* @lua NA
*/
~Profiler(void);
/** display the timers //显示
* @js NA
* @lua NA
*/
void displayTimers(void);
/**
* @js NA
* @lua NA
*/
bool init(void);
public:
/** returns the singleton
* @js NA
* @lua NA
*/
static Profiler* getInstance(void);
/**
* @js NA
* @lua NA
*/
CC_DEPRECATED_ATTRIBUTE static Profiler* sharedProfiler(void);
/** Creates and adds a new timer
* @js NA
* @lua NA
*/
ProfilingTimer* createAndAddTimerWithName(const char* timerName);
/** releases a timer
* @js NA
* @lua NA
*/
void releaseTimer(const char* timerName);
/** releases all timers
* @js NA
* @lua NA
*/
void releaseAllTimers();
Dictionary* _activeTimers;
};
class ProfilingTimer : public Object
{
public:
/**
* @js NA
* @lua NA
*/
ProfilingTimer();
/**
* @js NA
* @lua NA
*/
~ProfilingTimer(void);
/**
* @js NA
* @lua NA
*/
bool initWithName(const char* timerName);
/**
* @js NA
* @lua NA
*/
const char* description(void) const;
/**
* @js NA
* @lua NA
*/
inline const std::chrono::high_resolution_clock::time_point& getStartTime(void) { return _startTime; };
/** resets the timer properties
* @js NA
* @lua NA
*/
void reset();
std::string _nameStr;
std::chrono::high_resolution_clock::time_point _startTime;
int _averageTime1;
int _averageTime2;
int minTime;
int maxTime;
long long totalTime;
int numberOfCalls;
};
extern void ProfilingBeginTimingBlock(const char *timerName);
extern void ProfilingEndTimingBlock(const char *timerName);
extern void ProfilingResetTimingBlock(const char *timerName);
/*
* cocos2d profiling categories
* used to enable / disable profilers with granularity
*/
extern bool kProfilerCategorySprite;
extern bool kProfilerCategoryBatchSprite;
extern bool kProfilerCategoryParticles;
// end of global group
/// @}
NS_CC_END
#endif // __SUPPORT_CCPROFILING_H__