Open Reality Reference Guide
 
Loading...
Searching...
No Matches
fbprofiler.h
1#ifndef __FBPROFILER_H__
2#define __FBPROFILER_H__
3/**************************************************************************
4 Copyright (c) 1994 - 2009 Autodesk, Inc. and/or its licensors.
5 All Rights Reserved.
6
7 The coded instructions, statements, computer programs, and/or related
8 material (collectively the "Data") in these files contain unpublished
9 information proprietary to Autodesk, Inc. and/or its licensors, which is
10 protected by Canada and United States of America federal copyright law
11 and by international treaties.
12
13 The Data may not be disclosed or distributed to third parties, in whole
14 or in part, without the prior written consent of Autodesk, Inc.
15 ("Autodesk").
16
17 THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
18 ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
19 WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR
20 ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES
21 OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
22 PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT
23 WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR
24 FREE.
25
26 IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
27 OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR
28 EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE
29 DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS
30 OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR
31 DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF
32 LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT
33 LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE
34 DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS
35 BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
36
37**************************************************************************/
38
39#include <kaydaradef.h>
40#ifndef FBSDK_DLL
44 #define FBSDK_DLL K_DLLIMPORT
45#endif
46
47#include <fbsdk/fbcomponent.h>
48#include <fbsdk/fbcore.h>
49
50#ifdef FBSDKUseNamespace
51 namespace FBSDKNamespace {
52#endif
53
60#define FBProfiler_CreateTaskCycle( pClass, pR, pG, pB ) \
61 int gProfilingIndex_##pClass = -1; \
62 float gProfilingColor_##pClass[3] = { pR, pG, pB };
63
69#define FBProfiling_SetupTaskCycle( pClass ) \
70 if(gProfilingIndex_##pClass == -1) \
71 gProfilingIndex_##pClass = FBProfiler::TheOne().RegisterTaskCycle(#pClass,gProfilingColor_##pClass);
72
78#define FBProfiling_TaskCycleIndex( pClass ) \
79 gProfilingIndex_##pClass
80
87
129{
130public:
131 int GetIndex();
132 const char* GetName();
133 const float* GetColor();
134
141 void GetAvgMinMaxUsage(double& pAvg, double& pMin, double& pMax);
142
143 // Sampling.
144 void Start();
145 void Stop();
146 bool IsStarted();
147
154
161private:
163
168 FBProfileTaskCycle & operator =(const FBProfileTaskCycle &);
170};
171
173// FBProfileTimeEvent
175
185{
186public:
188 const float* GetColor();
189
190 const char* GetTypeName();
191 const char* GetComment();
193
195private:
197
202 FBProfileTimeEvent & operator =(const FBProfileTimeEvent &);
204};
205
207enum FBProfilingMode
208{
209 kFBProfilingModeDisabled = 0,
210 kFBProfilingModeEvaluation,
211 kFBProfilingModeRendering,
212 kFBProfilingModeDevices,
213 kFBProfilingModeSDK,
214 kFBProfilingModeAllLow,
215 kFBProfilingModeAllHi
216};
217
218FB_DEFINE_ENUM(FBSDK_DLL, ProfilingMode);
219
221// FBProfiler
223
228public:
232 FBProfiler(HIObject pObject=NULL);
233
234 FBPropertyProfilingMode ProfilingMode;
239
240 // Event samples.
255
256 // Stats (for now only IO)
257
266 int GetStatIndex(const char* pName);
271 const char* GetStatName(int pIndex);
276 const char* GetStatComment(int pIndex);
277
282 double GetStatStart(int pIndex);
283
288 double GetStatStop(int pIndex);
289
294 double GetStatDuration(int pIndex);
295
300
306 static int RegisterTaskCycle(const char* pUniqueName, float* pColor = NULL);
307
312 static bool IsTaskCycleNameRegistered(const char* pName);
313
318};
319
321// FBProfilerHelper
323
327{
328public:
335 FBProfilerHelper(int pTC_RegisterationIndex, FBEvaluateInfo* pEvaluateInfo, FBProfileTaskCycle* pParentTaskCycle = NULL);
340
342 void Stop();
343
345 inline bool IsStarted() { return mCurrentTaskCycle != NULL; }
346private:
348 FBEvaluateInfo* mEvaluateInfo;
349 FBProfileTaskCycle* mBackupTaskCycle;
350 FBProfileTaskCycle* mCurrentTaskCycle;
352};
353
354
356// GLOBALS, for querying of FBProfileTaskCycle hierarchy or to be used in FBProfilerHelper constructor.
358FBSDK_DLL FBProfileTaskCycle* FBGetMainThreadTaskCycle();
359FBSDK_DLL FBProfileTaskCycle* FBGetRenderingTaskCycle();
360FBSDK_DLL FBProfileTaskCycle* FBGetEvaluationTaskCycle();
361
362#ifdef FBSDKUseNamespace
363 }
364#endif
365
366#endif /* __FBPROFILER_H__ */
MotionBuilder SDK base class.
AnimationNodeNotify evaluation information.
FBProfileTaskCycle.
Definition fbprofiler.h:129
int GetIndex()
Get the unique registration index for each cycle.
void Start()
Start of task cycle sample. In most cases should be controlled by FBProfilerHelper.
void Stop()
Stop of task cycle sample. In most cases should be controlled by FBProfilerHelper.
const float * GetColor()
Get the color of the task cycle. Used in profiling Center for drawing.
int GetChildCount()
Get number of child tasks.
void GetAvgMinMaxUsage(double &pAvg, double &pMin, double &pMax)
Get the task cycle's average, minimum and maximum usage.
bool IsStarted()
Test to see if sampling has started.
const char * GetName()
Get the name of task cycle.
FBProfileTaskCycle * GetChild(int pIndex)
Get child task based on specific index.
FBProfileTimeEvent.
Definition fbprofiler.h:185
const float * GetColor()
Get the color assigned to the event.
const char * GetTypeName()
Get the event registered type name.
int GetThreadID()
Get the thread ID used in the event execution.
FBTime GetTime()
Get the time when the event occurred.
const char * GetComment()
Get the comment for the event. Comments are not editable.
bool IsSingleEvent()
Three types of events exits: single, start and end. Some actions that takes more time to execute or w...
FBProfilerHelper.
Definition fbprofiler.h:327
void Stop()
Stop sample. Can be done manually, before destruction of the object.
FBProfilerHelper(int pTC_RegisterationIndex, FBEvaluateInfo *pEvaluateInfo, FBProfileTaskCycle *pParentTaskCycle=NULL)
Constructor.
bool IsStarted()
Test to see if profiling is started. Useful to verify if profiling is in progress.
Definition fbprofiler.h:345
~FBProfilerHelper()
Destructor.
FBProfiler.
Definition fbprofiler.h:226
const char * GetStatComment(int pIndex)
Get aditional information about what action is stat refering to.
FBPropertyProfilingMode ProfilingMode
Read/Write Property: Profiling collection modes, including disabling all profiling.
Definition fbprofiler.h:234
FBPropertyInt BufferSize
Read/Write Property: Buffer size for average and timing computation (maximum value 200).
Definition fbprofiler.h:236
const char * GetStatName(int pIndex)
Get information about what action is stat refering to.
static int RegisterTaskCycle(const char *pUniqueName, float *pColor=NULL)
Register a new task cycle for profiling.
FBPropertyInt EvaluationDepth
Read/Write Property: Specify the depth of evaluation profiling for data collection (maximum value is ...
Definition fbprofiler.h:235
FBProfileTimeEvent * GetEventSample(int pIndex)
Only possible way to query collected FBProfileTimeEvent.
double GetProfilingCost()
Profiling collection can affect scene performace.
int GetStatIndex(const char *pName)
Search for index of given stat name.
int GetEventSampleCount()
Get number of time event samples collected during last sampling.
double GetStatDuration(int pIndex)
Get time that was spend on execution of action.
FBProfiler(HIObject pObject=NULL)
Constructor.
int GetStatCount()
Stats are holding last execution time/duration of action.
FBProfileTimeEvent * GetEndEventSample(int pIndex)
Get end time event for event at given index.
double GetStatStop(int pIndex)
Get stop time of action.
double GetStatStart(int pIndex)
Get start time of action.
static bool IsTaskCycleNameRegistered(const char *pName)
Test to see if a task cycle is already registered based on the name provided.
FBPropertyBool ActiveSampling
Read/Write Property: Activate the sampling for time events. Call before quering for FBProfileTimeEven...
Definition fbprofiler.h:238
FBPropertyBool FrameReference
Read/Write Property: Draw task cycles in relation to main thread cycle time - frame cycle (percentage...
Definition fbprofiler.h:237
static FBProfiler & TheOne()
Get the global object for this class.
Time data structure.
Definition fbtime.h:88
Basic class definitions.
#define __FBClassDeclare(Name, Parent)
For internal use only.
#define FBSDK_DLL
Be sure that FBSDK_DLL is defined only once...
Contains definitions for devices, boxes and models.
class K_DLLIMPORT FBPropertyBase< int, kFBPT_int > FBPropertyInt
Property: int
class K_DLLIMPORT FBPropertyBase< bool, kFBPT_bool > FBPropertyBool
Property: bool
#define FB_DEFINE_ENUM(DllTag, Type)
Define an enum and give it the ability to be a property.
#define FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition fbtypes.h:62
#define __FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition fbtypes.h:68