Go to the
documentation of this file.
00001 #ifndef __FBPROFILER_H__
00002 #define __FBPROFILER_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include <kaydaradef.h>
00040 #ifndef FBSDK_DLL
00041
00044 #define FBSDK_DLL K_DLLIMPORT
00045 #endif
00046
00047 #include <fbsdk/fbcomponent.h>
00048 #include <fbsdk/fbcore.h>
00049
00050 #ifdef FBSDKUseNamespace
00051 namespace FBSDKNamespace {
00052 #endif
00053
00060 #define FBProfiler_CreateTaskCycle( pClass, pR, pG, pB ) \
00061 int gProfilingIndex_##pClass = -1; \
00062 float gProfilingColor_##pClass[3] = { pR, pG, pB };
00063
00069 #define FBProfiling_SetupTaskCycle( pClass ) \
00070 if(gProfilingIndex_##pClass == -1) \
00071 gProfilingIndex_##pClass = FBProfiler::TheOne().RegisterTaskCycle(#pClass,gProfilingColor_##pClass);
00072
00078 #define FBProfiling_TaskCycleIndex( pClass ) \
00079 gProfilingIndex_##pClass
00080
00082 __FB_FORWARD(FBProfiler);
00083 FB_FORWARD(FBProfileTaskCycle);
00084 __FB_FORWARD(FBProfileTimeEvent);
00085 FB_FORWARD(FBEvaluateInfo);
00086 FB_FORWARD(FBProfilerHelper);
00087
00128 class FBSDK_DLL FBProfileTaskCycle
00129 {
00130 public:
00131 int GetIndex();
00132 const char* GetName();
00133 const float* GetColor();
00134
00141 void GetAvgMinMaxUsage(double& pAvg, double& pMin, double& pMax);
00142
00143
00144 void Start();
00145 void Stop();
00146 bool IsStarted();
00147
00153 int GetChildCount();
00154
00160 HFBProfileTaskCycle GetChild(int pIndex);
00161 private:
00163
00164 FBProfileTaskCycle();
00166 FBProfileTaskCycle(const FBProfileTaskCycle &);
00168 FBProfileTaskCycle & operator =(const FBProfileTaskCycle &);
00170 };
00171
00173
00175
00184 class FBSDK_DLL FBProfileTimeEvent
00185 {
00186 public:
00187 FBTime GetTime();
00188 const float* GetColor();
00189
00190 const char* GetComment();
00191 int GetThreadID();
00192
00193 bool IsSingleEvent();
00194 private:
00196
00197 FBProfileTimeEvent();
00199 FBProfileTimeEvent(const FBProfileTimeEvent &);
00201 FBProfileTimeEvent & operator =(const FBProfileTimeEvent &);
00203 };
00204
00206 enum FBProfilingMode
00207 {
00208 kFBProfilingModeDisabled = 0,
00209 kFBProfilingModeEvaluation,
00210 kFBProfilingModeRendering,
00211 kFBProfilingModeDevices,
00212 kFBProfilingModeSDK,
00213 kFBProfilingModeAllLow,
00214 kFBProfilingModeAllHi
00215 };
00216
00217 FB_DEFINE_ENUM(FBSDK_DLL, ProfilingMode);
00218
00220
00222
00225 class FBSDK_DLL FBProfiler : public FBComponent {
00226 __FBClassDeclare( FBProfiler,FBComponent );
00227 public:
00231 FBProfiler(HIObject pObject=NULL);
00232
00233 FBPropertyProfilingMode ProfilingMode;
00234 FBPropertyInt EvaluationDepth;
00235 FBPropertyInt BufferSize;
00236 FBPropertyBool FrameReference;
00237 FBPropertyBool ActiveSampling;
00238
00239
00243 int GetEventSampleCount();
00248 HFBProfileTimeEvent GetEventSample( int pIndex );
00253 HFBProfileTimeEvent GetEndEventSample( int pIndex );
00254
00255
00256
00260 int GetStatCount();
00265 int GetStatIndex(const char* pName);
00270 const char* GetStatName(int pIndex);
00275 const char* GetStatComment(int pIndex);
00280 double GetStatDuration(int pIndex);
00281
00285 double GetProfilingCost();
00286
00292 static int RegisterTaskCycle(const char* pUniqueName, float* pColor = NULL);
00293
00298 static bool IsTaskCycleNameRegistered(const char* pName);
00299
00303 static FBProfiler& TheOne();
00304 };
00305
00307
00309
00312 class FBSDK_DLL FBProfilerHelper
00313 {
00314 public:
00321 FBProfilerHelper(int pTC_RegisterationIndex, HFBEvaluateInfo pEvaluateInfo, HFBProfileTaskCycle pParentTaskCycle = NULL);
00325 ~FBProfilerHelper();
00326
00328 void Stop();
00329
00331 inline bool IsStarted() { return mCurrentTaskCycle != NULL; }
00332 private:
00334 HFBEvaluateInfo mEvaluateInfo;
00335 HFBProfileTaskCycle mBackupTaskCycle;
00336 HFBProfileTaskCycle mCurrentTaskCycle;
00338 };
00339
00340
00342
00344 FBSDK_DLL HFBProfileTaskCycle FBGetMainThreadTaskCycle();
00345 FBSDK_DLL HFBProfileTaskCycle FBGetRenderingTaskCycle();
00346 FBSDK_DLL HFBProfileTaskCycle FBGetEvaluationTaskCycle();
00347
00348 #ifdef FBSDKUseNamespace
00349 }
00350 #endif
00351
00352 #endif