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);
365 void removeAllProfiles();
370 const char *profile_name);
373 void changeProfileRecordOptions(
387 {
return myActiveProfileId; }
395 int numCompletedProfiles()
const;
404 int getProfileByFilePath(
405 const char *file_path)
const;
409 void addProfileInterest(
415 void removeProfileInterest(
421 bool hasProfileInterest(
428 void addEventInterest(
434 void changeEventInterestRecordOptions(
440 void removeEventInterest(
446 bool hasEventInterest(
452 int createDiffProfile(
int id1,
int id2);
463 return myIsRecordingCount.load() > 0 ||
464 (!profile_only && getDisplayNodeInfo());
469 return myRecordCookStatsCount.load() > 0 ||
470 (!profile_only && getDisplayNodeInfo());
475 return myRecordPDGCookStatsCount.load() > 0;
480 return myRecordSolveStatsCount.load() > 0;
486 myRecordObjectDrawStatsCount.load() > 0;
492 myRecordObjectGPUDrawStatsCount.load() > 0;
497 return myRecordViewportStatsCount.load() > 0;
502 return myRecordPaneStatsCount.load() > 0;
507 return myRecordScriptStatsCount.load() > 0;
512 return myRecordRenderStatsCount.load() > 0;
517 return myRecordThreadStatsCount.load() > 0;
522 return myRecordFrameStatsCount.load() > 0;
527 return myRecordMemoryStatsCount.load() > 0;
532 return myRecordErrorsCount.load() > 0;
539 virtual bool isRecordingAllowedFor(
OP_Node* node)
const;
548 {
return myTimedFrameEventCounter; }
553 {
return myMemoryFrameEventCounter; }
558 {
return myTotalFrameTime; }
563 {
return myTotalFrameMemory; }
566 void resetCumulativeFrameStats();
584 void setDisplayNodeInfo(
bool display);
586 {
return myDisplayNodeInfo; }
593 const UT_Ramp &getRampColorScheme()
const;
596 void setRampColorScheme(
const UT_Ramp &src_ramp);
599 void loadRampColorScheme(
const char *str_color_scheme);
602 void saveRampColorScheme(
UT_String &str_color_scheme);
605 const UT_Ramp &getDefaultColorRampScheme();
618 virtual int getCurrentFrameSubclass_();
621 virtual OP_Node *getNodeSubclass_(
int node_id)
const;
624 virtual OP_Node *getNodeFromSolverSubclass_(
629 virtual void getObjectPathFromNodeSubclass_(
630 OP_Node *node,
const char *event_name,
635 virtual void getObjectPathFromSolverAndNodeSubclass_(
642 virtual void getExtraInfoFromNodeSubclass_(
668 bool auto_nest_events,
679 int node_id,
const char *cook_event_name);
685 const char *pdg_event_name);
688 int startSolveEvent_(
691 const char *solver_event_name);
697 const char *draw_event_name,
701 int startViewportDrawEvent_(
703 const char *viewport_name,
704 const char *draw_event_name,
709 int startGenericDrawEvent_(
712 const char *draw_event_name,
714 const char *object_icon,
718 int startScriptEvent_(
720 const char *code_description,
722 bool auto_nest_events,
726 int startRenderEvent_(
728 const char *renderer,
729 const char *operation,
730 bool is_renderer_a_node,
745 void incrementRecordingCounters_(
749 void decrementRecordingCounters_(
761 int getProfileByFilePath_(
const char *file_path)
const;
765 void addFilePathToLoadedProfileMapping_(
766 const char *file_path,
772 void removeFilePathToLoadedProfileMapping_(
int profile_id);
776 void clearFilePathToLoadedProfileMappings_();
780 UT_String convertFilePathToCanonicalForm_(
787 bool is_cancelled=
false);
791 void findAndLinkToRunningParentEvent_(
796 bool for_memory_event,
797 bool require_auto_nest);
799 void addChildToRunningParentEvent_(
802 bool for_memory_event,
803 bool require_auto_nest);
810 bool for_memory_event);
817 bool for_memory_event)
const;
822 void removeFromRunningEventList_(
828 void addToRunningEventList_(
833 void resetRunningEventLists_();
840 int findProfileInterest_(
void *callee,
844 void notifyProfileInterests_(
850 int findEventInterest_(
void *callee,
854 void notifyEventInterests_(
857 using RWLock = tbb::spin_rw_mutex;
860 RWLock &getRunningEventsLock_(
862 bool for_memory_event);
866 bool areOptionsInterestedInEvent_(
871 fpreal stopEvent_(
int event_id,
bool return_value);
875 void addToCumulativeFrameStats_(
876 fpreal frame_value,
bool is_memory_value);
879 void initDefaultColorRampScheme_();
882 int myActiveProfileId;
886 bool myDisplayNodeInfo;
905 mutable RWLock myEventsLock;
906 mutable RWLock myProfilesLock;
907 mutable RWLock myProfileInterestsLock;
908 mutable RWLock myEventInterestsLock;
943 fpreal myTotalFrameMemory;
944 int myTimedFrameEventCounter;
945 int myMemoryFrameEventCounter;
GLuint GLsizei const GLchar * message
UT_PerfMonEventType
Event types.
GT_API const UT_StringHolder time
GLsizei const GLchar *const * path
Class which writes ASCII or binary JSON streams.
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.