cocos2d-x节点(CCProfiling.h)API

本文来自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__


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值