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* GetTypeName();
00191 const char* GetComment();
00192 int GetThreadID();
00193
00194 bool IsSingleEvent();
00195 private:
00197
00198 FBProfileTimeEvent();
00200 FBProfileTimeEvent(const FBProfileTimeEvent &);
00202 FBProfileTimeEvent & operator =(const FBProfileTimeEvent &);
00204 };
00205
00207 enum FBProfilingMode
00208 {
00209 kFBProfilingModeDisabled = 0,
00210 kFBProfilingModeEvaluation,
00211 kFBProfilingModeRendering,
00212 kFBProfilingModeDevices,
00213 kFBProfilingModeSDK,
00214 kFBProfilingModeAllLow,
00215 kFBProfilingModeAllHi
00216 };
00217
00218 FB_DEFINE_ENUM(FBSDK_DLL, ProfilingMode);
00219
00221
00223
00226 class FBSDK_DLL FBProfiler : public FBComponent {
00227 __FBClassDeclare( FBProfiler,FBComponent );
00228 public:
00232 FBProfiler(HIObject pObject=NULL);
00233
00234 FBPropertyProfilingMode ProfilingMode;
00235 FBPropertyInt EvaluationDepth;
00236 FBPropertyInt BufferSize;
00237 FBPropertyBool FrameReference;
00238 FBPropertyBool ActiveSampling;
00239
00240
00244 int GetEventSampleCount();
00249 HFBProfileTimeEvent GetEventSample( int pIndex );
00254 HFBProfileTimeEvent GetEndEventSample( int pIndex );
00255
00256
00257
00261 int GetStatCount();
00266 int GetStatIndex(const char* pName);
00271 const char* GetStatName(int pIndex);
00276 const char* GetStatComment(int pIndex);
00281 double GetStatDuration(int pIndex);
00282
00286 double GetProfilingCost();
00287
00293 static int RegisterTaskCycle(const char* pUniqueName, float* pColor = NULL);
00294
00299 static bool IsTaskCycleNameRegistered(const char* pName);
00300
00304 static FBProfiler& TheOne();
00305 };
00306
00308
00310
00313 class FBSDK_DLL FBProfilerHelper
00314 {
00315 public:
00322 FBProfilerHelper(int pTC_RegisterationIndex, FBEvaluateInfo* pEvaluateInfo, HFBProfileTaskCycle pParentTaskCycle = NULL);
00326 ~FBProfilerHelper();
00327
00329 void Stop();
00330
00332 inline bool IsStarted() { return mCurrentTaskCycle != NULL; }
00333 private:
00335 FBEvaluateInfo* mEvaluateInfo;
00336 HFBProfileTaskCycle mBackupTaskCycle;
00337 HFBProfileTaskCycle mCurrentTaskCycle;
00339 };
00340
00341
00343
00345 FBSDK_DLL HFBProfileTaskCycle FBGetMainThreadTaskCycle();
00346 FBSDK_DLL HFBProfileTaskCycle FBGetRenderingTaskCycle();
00347 FBSDK_DLL HFBProfileTaskCycle FBGetEvaluationTaskCycle();
00348
00349 #ifdef FBSDKUseNamespace
00350 }
00351 #endif
00352
00353 #endif