fbsdk/fbprofiler.h Source File

fbprofiler.h
Go to the documentation of this file.
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
41 
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 
82 __FB_FORWARD(FBProfiler);
83 FB_FORWARD(FBProfileTaskCycle);
84 __FB_FORWARD(FBProfileTimeEvent);
85 FB_FORWARD(FBEvaluateInfo);
86 FB_FORWARD(FBProfilerHelper);
87 
129 {
130 public:
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 
153  int GetChildCount();
154 
160  FBProfileTaskCycle* GetChild(int pIndex);
161 private:
168  FBProfileTaskCycle & operator =(const FBProfileTaskCycle &);
170 };
171 
173 // FBProfileTimeEvent
175 
185 {
186 public:
187  FBTime GetTime();
188  const float* GetColor();
189 
190  const char* GetTypeName();
191  const char* GetComment();
192  int GetThreadID();
193 
194  bool IsSingleEvent();
195 private:
202  FBProfileTimeEvent & operator =(const FBProfileTimeEvent &);
204 };
205 
208 {
216 };
217 
218 FB_DEFINE_ENUM(FBSDK_DLL, ProfilingMode);
219 
221 // FBProfiler
223 
228 public:
232  FBProfiler(HIObject pObject=NULL);
233 
239 
240  // Event samples.
244  int GetEventSampleCount();
249  FBProfileTimeEvent* GetEventSample( int pIndex );
254  FBProfileTimeEvent* GetEndEventSample( int pIndex );
255 
256  // Stats (for now only IO)
257 
261  int GetStatCount();
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 
299  double GetProfilingCost();
300 
306  static int RegisterTaskCycle(const char* pUniqueName, float* pColor = NULL);
307 
312  static bool IsTaskCycleNameRegistered(const char* pName);
313 
317  static FBProfiler& TheOne();
318 };
319 
321 // FBProfilerHelper
323 
327 {
328 public:
335  FBProfilerHelper(int pTC_RegisterationIndex, FBEvaluateInfo* pEvaluateInfo, FBProfileTaskCycle* pParentTaskCycle = NULL);
339  ~FBProfilerHelper();
340 
342  void Stop();
343 
345  inline bool IsStarted() { return mCurrentTaskCycle != NULL; }
346 private:
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.
358 FBSDK_DLL FBProfileTaskCycle* FBGetMainThreadTaskCycle();
359 FBSDK_DLL FBProfileTaskCycle* FBGetRenderingTaskCycle();
360 FBSDK_DLL FBProfileTaskCycle* FBGetEvaluationTaskCycle();
361 
362 #ifdef FBSDKUseNamespace
363  }
364 #endif
365 
366 #endif /* __FBPROFILER_H__ */
#define __FBClassDeclare(Name, Parent)
For internal use only.
Definition: fbcomponent.h:132
Time data structure.
Definition: fbtime.h:86
class FBPropertyBaseEnum< enum FBProfilingMode > FBPropertyProfilingMode
Definition: fbprofiler.h:218
Collect profiling for all known tasks .
Definition: fbprofiler.h:215
#define FBSDK_DLL
Be sure that FBSDK_DLL is defined only once...
Definition: fbprofiler.h:44
bool IsStarted()
Test to see if profiling is started. Useful to verify if profiling is in progress.
Definition: fbprofiler.h:345
FBProfilerHelper.
Definition: fbprofiler.h:326
FBPropertyBool FrameReference
Read/Write Property: Draw task cycles in relation to main thread cycle time - frame cycle (percentage...
Definition: fbprofiler.h:237
#define NULL
Definition: kaydara.h:179
FBProfileTaskCycle * FBGetMainThreadTaskCycle()
Get root task cycle.
class FBPropertyBase< int, kFBPT_int > FBPropertyInt
Property: int
Contains definitions for devices, boxes and models.
#define FB_DEFINE_ENUM(DllTag, Type)
Define an enum and give it the ability to be a property.
Definition: fbproperties.h:148
FBPropertyInt BufferSize
Read/Write Property: Buffer size for average and timing computation (maximum value 200)...
Definition: fbprofiler.h:236
FBPropertyProfilingMode ProfilingMode
Read/Write Property: Profiling collection modes, including disabling all profiling.
Definition: fbprofiler.h:234
FBProfileTaskCycle * FBGetEvaluationTaskCycle()
Get evaluation task cycle.
Collect profiling for device Input/Output and Device Evaluation.
Definition: fbprofiler.h:212
FBProfilingMode
Available Profiling modes.
Definition: fbprofiler.h:207
#define __FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:68
#define FBSDKNamespace
FBSDKNamespace define.
Definition: fbversion.h:64
FBProfileTaskCycle.
Definition: fbprofiler.h:128
Basic class definitions.
FBPropertyInt EvaluationDepth
Read/Write Property: Specify the depth of evaluation profiling for data collection (maximum value is ...
Definition: fbprofiler.h:235
All profiling disabled, this include Viewer profiling.
Definition: fbprofiler.h:209
MotionBuilder SDK base class.
Definition: fbcomponent.h:664
#define FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:62
Collect profiling for all known rendering tasks.
Definition: fbprofiler.h:211
FBProfileTaskCycle * FBGetRenderingTaskCycle()
Get rendering task cycle.
AnimationNodeNotify evaluation information.
Collect profiling for all known tasks that doesn't increase remarkably with scene size...
Definition: fbprofiler.h:214
Collect profiling for all known evaluation tasks (default mode).
Definition: fbprofiler.h:210
Collect profiling for SDK.
Definition: fbprofiler.h:213
FBProfileTimeEvent.
Definition: fbprofiler.h:184
FBPropertyBool ActiveSampling
Read/Write Property: Activate the sampling for time events.
Definition: fbprofiler.h:238
class FBPropertyBase< bool, kFBPT_bool > FBPropertyBool
Property: bool