13 #ifndef __UT_Performance__ 
   14 #define __UT_Performance__ 
   30 #include <tbb/spin_rw_mutex.h> 
   32 #define UT_PERFMON_INVALID_ID   -1 
   33 #define UT_PERFMON_INTERNAL_TASKS_LABEL "Internal Tasks" 
   61 class ut_PerfMonProfileInterest;
 
   62 class ut_PerfMonEventInterest;
 
   87                                 bool auto_nest_events=
true);
 
   90                                 bool auto_nest_events=
true);
 
   95     int                      startTimedCookEvent(
 
   97                                 const char *cook_event_name=NULL);
 
   98     int                      startMemoryCookEvent(
 
  100                                 const char *cook_event_name=NULL);
 
  106     void                     addTimedCookEvent(
 
  109                                 const char *cook_event_name=NULL);
 
  114     int                      startTimedPDGEvent(
 
  116                                 const char *pdg_event_name=NULL);
 
  117     int                      startMemoryPDGEvent(
 
  119                                 const char *pdg_event_name=NULL);
 
  125     void                     addTimedPDGEvent(
 
  128                                 const char *pdg_event_name=NULL);
 
  134     int                      startTimedSolveEvent(
 
  136                                 const char *solver_event_name=NULL);
 
  137     int                      startMemorySolveEvent(
 
  139                                 const char *solver_event_name=NULL);
 
  145     int                      startTimedDrawEvent(
 
  147                                 const char *draw_event_name,
 
  148                                 bool is_gpu_draw=
false);
 
  149     int                      startMemoryDrawEvent(
 
  151                                 const char *draw_event_name,
 
  152                                 bool is_gpu_draw=
false);
 
  158     int                      startTimedViewportDrawEvent(
 
  159                                 const char *viewport_name, 
 
  160                                 const char *draw_event_name,
 
  162                                 bool is_gpu_draw=
false);
 
  163     int                      startMemoryViewportDrawEvent(
 
  164                                 const char *viewport_name, 
 
  165                                 const char *draw_event_name,
 
  167                                 bool is_gpu_draw=
false);
 
  173     void                     addTimedDrawEvent(
 
  175                                 const char *draw_event_name,
 
  177                                 bool is_gpu_draw=
false);
 
  183     void                     addTimedViewportDrawEvent(
 
  185                                 const char *draw_event_name,
 
  188                                 bool is_gpu_draw=
false);
 
  193     int                      startTimedScriptEvent(
 
  194                                 const char *code_description,
 
  196                                 bool auto_nest_events=
true);
 
  197     int                      startMemoryScriptEvent(
 
  198                                 const char *code_description,
 
  200                                 bool auto_nest_events=
true);
 
  204     int                      startTimedNodeScriptEvent(
 
  206                                 const char *code_description,
 
  208     int                      startMemoryNodeScriptEvent(
 
  210                                 const char *code_description,
 
  216     int                      startTimedRenderEvent(
 
  217                                 const char *renderer, 
 
  218                                 const char *operation, 
 
  219                                 bool is_renderer_a_node,
 
  221                                 const char *
object=NULL);
 
  222     int                      startMemoryRenderEvent(
 
  223                                 const char *renderer, 
 
  224                                 const char *operation, 
 
  225                                 bool is_renderer_a_node,
 
  227                                 const char *
object=NULL);
 
  233     void                     addTimedRenderEvent(
 
  235                                 bool is_renderer_a_node,
 
  238     void                     addMemoryRenderEvent(
 
  240                                 bool is_renderer_a_node,
 
  247     int                      startTimedFrameEvent(
fpreal frame);
 
  248     int                      startMemoryFrameEvent(
fpreal frame);
 
  252     int                      startTimedNodeCreationEvent();
 
  253     int                      startMemoryNodeCreationEvent();
 
  254     void                     stopNodeCreationEvent(
int event_id, 
int node_id);
 
  257     int                      startTimedPaneEvent(
const char *pane,
 
  258                                 const char *operation);
 
  259     int                      startMemoryPaneEvent(
const char *pane,
 
  260                                 const char *operation);
 
  267     fpreal                   stopEvent(
int event_id, 
bool return_value=
false);
 
  272     void                     cancelEvent(
int event_id);
 
  275     void                     logMessage(
const char *
message);
 
  290     virtual int              startTaskScope(
const UT_TaskScope* task_scope);
 
  294     virtual void             stopTaskScope(
 
  300     void                     setEventExtraInfo(
 
  301                                 int event_id, 
const char *extra_info) 
const;
 
  343                                 const char *file_path, 
 
  358                                 const char *file_path);
 
  367     void                     removeAllProfiles(
 
  368                                 bool include_recording_profiles=
true);
 
  373                                 const char *profile_name);
 
  376     void                     changeProfileRecordOptions(
 
  390                                 { 
return myActiveProfileId; }
 
  398     int                      numCompletedProfiles() 
const;
 
  407     int                      getProfileByFilePath(
 
  408                                 const char *file_path) 
const;
 
  412     void                     addProfileInterest(
 
  418     void                     removeProfileInterest(
 
  424     bool                     hasProfileInterest(
 
  431     void                     addEventInterest(
 
  437     void                     changeEventInterestRecordOptions(
 
  443     void                     removeEventInterest(
 
  449     bool                     hasEventInterest(
 
  455     int                      createDiffProfile(
int id1, 
int id2);
 
  466                                 return myIsRecordingCount.load() > 0 ||
 
  467                                     (!profile_only && getDisplayNodeInfo());
 
  472                                 return myRecordCookStatsCount.load() > 0 ||
 
  473                                     (!profile_only && getDisplayNodeInfo());
 
  478                                 return myRecordPDGCookStatsCount.load() > 0;
 
  483                                 return myRecordSolveStatsCount.load() > 0;
 
  489                                     myRecordObjectDrawStatsCount.load() > 0;
 
  495                                     myRecordObjectGPUDrawStatsCount.load() > 0;
 
  500                                 return myRecordViewportStatsCount.load() > 0;
 
  505                                 return myRecordPaneStatsCount.load() > 0;
 
  510                                 return myRecordScriptStatsCount.load() > 0;
 
  515                                 return myRecordRenderStatsCount.load() > 0;
 
  520                                 return myRecordThreadStatsCount.load() > 0;
 
  525                                 return myRecordFrameStatsCount.load() > 0;
 
  530                                 return myRecordMemoryStatsCount.load() > 0;
 
  535                                 return myRecordErrorsCount.load() > 0;
 
  542     virtual bool             isRecordingAllowedFor(
OP_Node* node) 
const;
 
  551                                 { 
return myTimedFrameEventCounter; }
 
  556                                 { 
return myMemoryFrameEventCounter; }
 
  561                                 { 
return myTotalFrameTime; }
 
  566                                 { 
return myTotalFrameMemory; }
 
  569     void                     resetCumulativeFrameStats();
 
  587     void                     setDisplayNodeInfo(
bool display);
 
  589                                 { 
return myDisplayNodeInfo; }
 
  596     const UT_Ramp           &getRampColorScheme() 
const;
 
  599     void                     setRampColorScheme(
const UT_Ramp &src_ramp);
 
  602     void                     loadRampColorScheme(
const char *str_color_scheme);
 
  605     void                     saveRampColorScheme(
UT_String &str_color_scheme);
 
  608     const UT_Ramp           &getDefaultColorRampScheme();
 
  621     virtual int              getCurrentFrameSubclass_();
 
  624     virtual OP_Node         *getNodeSubclass_(
int node_id) 
const;
 
  627     virtual OP_Node         *getNodeFromSolverSubclass_(
 
  632     virtual void             getObjectPathFromNodeSubclass_(
 
  633                                 OP_Node *node, 
const char *event_name,
 
  638     virtual void             getObjectPathFromSolverAndNodeSubclass_(
 
  645     virtual void             getExtraInfoFromNodeSubclass_(
 
  671                                 bool auto_nest_events,
 
  682                                 int node_id, 
const char *cook_event_name);
 
  688                                 const char *pdg_event_name);
 
  691     int                      startSolveEvent_(
 
  694                                 const char *solver_event_name);
 
  700                                 const char *draw_event_name,
 
  704     int                      startViewportDrawEvent_(
 
  706                                 const char *viewport_name, 
 
  707                                 const char *draw_event_name,
 
  712     int                      startGenericDrawEvent_(
 
  715                                 const char *draw_event_name,
 
  717                                 const char *object_icon,
 
  721     int                      startScriptEvent_(
 
  723                                 const char *code_description, 
 
  725                                 bool auto_nest_events,
 
  729     int                      startRenderEvent_(
 
  731                                 const char *renderer, 
 
  732                                 const char *operation, 
 
  733                                 bool is_renderer_a_node, 
 
  740                                 const char *pane_type, 
 
  741                                 const char *operation); 
 
  754     void                     incrementRecordingCounters_(
 
  758     void                     decrementRecordingCounters_(
 
  770     int                      getProfileByFilePath_(
const char *file_path) 
const;
 
  774     void                     addFilePathToLoadedProfileMapping_(
 
  775                                 const char *file_path,
 
  781     void                     removeFilePathToLoadedProfileMapping_(
int profile_id);
 
  785     void                     clearFilePathToLoadedProfileMappings_();
 
  789     UT_String                convertFilePathToCanonicalForm_(
 
  796                                 bool is_cancelled=
false);
 
  800     void                     findAndLinkToRunningParentEvent_(
 
  805                                 bool for_memory_event,
 
  806                                 bool require_auto_nest);
 
  808     void                     addChildToRunningParentEvent_(
 
  811                                 bool for_memory_event,
 
  812                                 bool require_auto_nest);
 
  819                                     bool for_memory_event);
 
  826                                     bool for_memory_event) 
const;
 
  831     void                     removeFromRunningEventList_(
 
  837     void                     addToRunningEventList_(
 
  842     void                     resetRunningEventLists_();
 
  849     int                      findProfileInterest_(
void *callee,
 
  853     void                     notifyProfileInterests_(
 
  859     int                      findEventInterest_(
void *callee,
 
  863     void                     notifyEventInterests_(
 
  866     using RWLock = tbb::spin_rw_mutex;
 
  869     RWLock                  &getRunningEventsLock_(
 
  871                                 bool for_memory_event);
 
  875     bool                     areOptionsInterestedInEvent_(
 
  880     fpreal                   stopEvent_(
int event_id, 
bool return_value);
 
  884     void                     addToCumulativeFrameStats_(
 
  885                                 fpreal frame_value, 
bool is_memory_value);
 
  888     void                     initDefaultColorRampScheme_();
 
  891     int                      myActiveProfileId;
 
  895     bool                     myDisplayNodeInfo;
 
  914     mutable RWLock           myEventsLock;
 
  915     mutable RWLock           myProfilesLock;
 
  916     mutable RWLock           myProfileInterestsLock;
 
  917     mutable RWLock           myEventInterestsLock;
 
  952     fpreal                   myTotalFrameMemory;
 
  953     int                      myTimedFrameEventCounter;
 
  954     int                      myMemoryFrameEventCounter;
 
GLuint GLsizei const GLchar * message
 
UT_PerfMonEventType
Event types. 
 
GT_API const UT_StringHolder time
 
GLsizei const GLfloat * value
 
GLsizei const GLchar *const * path
 
Class which writes ASCII or binary JSON streams. 
 
GLint GLint GLsizei GLint GLenum GLenum type
 
UT_PerfMonObjectType
Object types. 
 
static const UT_StringHolder theEmptyString
 
UT_PerfMonCategory
Categories. 
 
UT_PerfMonViewportType
Viewport types recognized by the performance monitor. 
 
A collection of statistics for a particular object (i.e. node, viewport). 
 
Utility class for containing a color ramp. 
 
GT_API const UT_StringHolder profile_id
 
UT_PerfMonScriptType
Script types recognized by the performance monitor.