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 FBProfileTaskCycle* 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 FBProfileTimeEvent* GetEventSample( int pIndex );
00254 FBProfileTimeEvent* 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);
00277
00282 double GetStatStart(int pIndex);
00283
00288 double GetStatStop(int pIndex);
00289
00294 double GetStatDuration(int pIndex);
00295
00299 double GetProfilingCost();
00300
00306 static int RegisterTaskCycle(const char* pUniqueName, float* pColor = NULL);
00307
00312 static bool IsTaskCycleNameRegistered(const char* pName);
00313
00317 static FBProfiler& TheOne();
00318 };
00319
00321
00323
00326 class FBSDK_DLL FBProfilerHelper
00327 {
00328 public:
00335 FBProfilerHelper(int pTC_RegisterationIndex, FBEvaluateInfo* pEvaluateInfo, FBProfileTaskCycle* pParentTaskCycle = NULL);
00339 ~FBProfilerHelper();
00340
00342 void Stop();
00343
00345 inline bool IsStarted() { return mCurrentTaskCycle != NULL; }
00346 private:
00348 FBEvaluateInfo* mEvaluateInfo;
00349 FBProfileTaskCycle* mBackupTaskCycle;
00350 FBProfileTaskCycle* mCurrentTaskCycle;
00352 };
00353
00354
00356
00358 FBSDK_DLL FBProfileTaskCycle* FBGetMainThreadTaskCycle();
00359 FBSDK_DLL FBProfileTaskCycle* FBGetRenderingTaskCycle();
00360 FBSDK_DLL FBProfileTaskCycle* FBGetEvaluationTaskCycle();
00361
00362 #ifdef FBSDKUseNamespace
00363 }
00364 #endif
00365
00366 #endif