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"
62 class ut_PerfMonProfileInterest;
63 class ut_PerfMonEventInterest;
88 bool auto_nest_events=
true);
91 bool auto_nest_events=
true);
96 int startTimedCookEvent(
98 const char *cook_event_name=NULL);
99 int startMemoryCookEvent(
101 const char *cook_event_name=NULL);
107 void addTimedCookEvent(
110 const char *cook_event_name=NULL);
115 int startTimedPDGEvent(
117 const char *pdg_event_name=NULL);
118 int startMemoryPDGEvent(
120 const char *pdg_event_name=NULL);
126 void addTimedPDGEvent(
129 const char *pdg_event_name=NULL);
135 int startTimedSolveEvent(
137 const char *solver_event_name=NULL);
138 int startMemorySolveEvent(
140 const char *solver_event_name=NULL);
146 int startTimedDrawEvent(
148 const char *draw_event_name,
149 bool is_gpu_draw=
false);
150 int startMemoryDrawEvent(
152 const char *draw_event_name,
153 bool is_gpu_draw=
false);
159 int startTimedViewportDrawEvent(
160 const char *viewport_name,
161 const char *draw_event_name,
163 bool is_gpu_draw=
false);
164 int startMemoryViewportDrawEvent(
165 const char *viewport_name,
166 const char *draw_event_name,
168 bool is_gpu_draw=
false);
174 void addTimedDrawEvent(
176 const char *draw_event_name,
178 bool is_gpu_draw=
false);
184 void addTimedViewportDrawEvent(
186 const char *draw_event_name,
189 bool is_gpu_draw=
false);
194 int startTimedScriptEvent(
195 const char *code_description,
197 bool auto_nest_events=
true);
198 int startMemoryScriptEvent(
199 const char *code_description,
201 bool auto_nest_events=
true);
205 int startTimedNodeScriptEvent(
207 const char *code_description,
209 int startMemoryNodeScriptEvent(
211 const char *code_description,
217 int startTimedRenderEvent(
218 const char *renderer,
219 const char *operation,
220 bool is_renderer_a_node,
222 const char *
object=NULL);
223 int startMemoryRenderEvent(
224 const char *renderer,
225 const char *operation,
226 bool is_renderer_a_node,
228 const char *
object=NULL);
234 void addTimedRenderEvent(
236 bool is_renderer_a_node,
239 void addMemoryRenderEvent(
241 bool is_renderer_a_node,
248 int startTimedFrameEvent(
fpreal frame);
249 int startMemoryFrameEvent(
fpreal frame);
253 int startTimedNodeCreationEvent();
254 int startMemoryNodeCreationEvent();
255 void stopNodeCreationEvent(
int event_id,
int node_id);
258 int startTimedPaneEvent(
const char *pane,
259 const char *operation);
260 int startMemoryPaneEvent(
const char *pane,
261 const char *operation);
268 fpreal stopEvent(
int event_id,
bool return_value=
false);
273 void cancelEvent(
int event_id);
276 void logMessage(
const char *
message);
291 virtual int startTaskScope(
const UT_TaskScope* task_scope);
295 virtual void stopTaskScope(
301 void setEventExtraInfo(
302 int event_id,
const char *extra_info)
const;
344 const char *file_path,
359 const char *file_path);
368 void removeAllProfiles(
369 bool include_recording_profiles=
true);
374 const char *profile_name);
377 void changeProfileRecordOptions(
391 {
return myActiveProfileId; }
399 int numCompletedProfiles()
const;
408 int getProfileByFilePath(
409 const char *file_path)
const;
413 void addProfileInterest(
419 void removeProfileInterest(
425 bool hasProfileInterest(
432 void addEventInterest(
438 void changeEventInterestRecordOptions(
444 void removeEventInterest(
450 bool hasEventInterest(
456 int createDiffProfile(
int id1,
int id2);
467 return myIsRecordingCount.load() > 0 ||
468 (!profile_only && getDisplayNodeInfo());
473 return myRecordCookStatsCount.load() > 0 ||
474 (!profile_only && getDisplayNodeInfo());
479 return myRecordPDGCookStatsCount.load() > 0;
484 return myRecordSolveStatsCount.load() > 0;
490 myRecordObjectDrawStatsCount.load() > 0;
496 myRecordObjectGPUDrawStatsCount.load() > 0;
501 return myRecordViewportStatsCount.load() > 0;
506 return myRecordPaneStatsCount.load() > 0;
511 return myRecordScriptStatsCount.load() > 0;
516 return myRecordRenderStatsCount.load() > 0;
521 return myRecordThreadStatsCount.load() > 0;
526 return myRecordFrameStatsCount.load() > 0;
531 return myRecordMemoryStatsCount.load() > 0;
536 return myRecordErrorsCount.load() > 0;
543 virtual bool isRecordingAllowedFor(
OP_Node* node)
const;
552 {
return myTimedFrameEventCounter; }
557 {
return myMemoryFrameEventCounter; }
562 {
return myTotalFrameTime; }
567 {
return myTotalFrameMemory; }
570 void resetCumulativeFrameStats();
588 void setDisplayNodeInfo(
bool display);
590 {
return myDisplayNodeInfo; }
597 const UT_Ramp &getRampColorScheme()
const;
600 void setRampColorScheme(
const UT_Ramp &src_ramp);
603 void loadRampColorScheme(
const char *str_color_scheme);
606 void saveRampColorScheme(
UT_String &str_color_scheme);
609 const UT_Ramp &getDefaultColorRampScheme();
622 virtual int getCurrentFrameSubclass_();
625 virtual OP_Node *getNodeSubclass_(
int node_id)
const;
628 virtual OP_Node *getNodeFromSolverSubclass_(
633 virtual void getObjectPathFromNodeSubclass_(
634 OP_Node *node,
const char *event_name,
639 virtual void getObjectPathFromSolverAndNodeSubclass_(
646 virtual void getExtraInfoFromNodeSubclass_(
672 bool auto_nest_events,
683 int node_id,
const char *cook_event_name);
689 const char *pdg_event_name);
692 int startSolveEvent_(
695 const char *solver_event_name);
701 const char *draw_event_name,
705 int startViewportDrawEvent_(
707 const char *viewport_name,
708 const char *draw_event_name,
713 int startGenericDrawEvent_(
716 const char *draw_event_name,
718 const char *object_icon,
722 int startScriptEvent_(
724 const char *code_description,
726 bool auto_nest_events,
730 int startRenderEvent_(
732 const char *renderer,
733 const char *operation,
734 bool is_renderer_a_node,
741 const char *pane_type,
742 const char *operation);
755 void incrementRecordingCounters_(
759 void decrementRecordingCounters_(
771 int getProfileByFilePath_(
const char *file_path)
const;
775 void addFilePathToLoadedProfileMapping_(
776 const char *file_path,
782 void removeFilePathToLoadedProfileMapping_(
int profile_id);
786 void clearFilePathToLoadedProfileMappings_();
790 UT_String convertFilePathToCanonicalForm_(
797 bool is_cancelled=
false);
801 void findAndLinkToRunningParentEvent_(
806 bool for_memory_event,
807 bool require_auto_nest);
809 void addChildToRunningParentEvent_(
812 bool for_memory_event,
813 bool require_auto_nest);
820 bool for_memory_event);
827 bool for_memory_event)
const;
832 void removeFromRunningEventList_(
838 void addToRunningEventList_(
843 void resetRunningEventLists_();
850 int findProfileInterest_(
void *callee,
854 void notifyProfileInterests_(
860 int findEventInterest_(
void *callee,
864 void notifyEventInterests_(
867 using RWLock = tbb::spin_rw_mutex;
870 RWLock &getRunningEventsLock_(
872 bool for_memory_event);
876 bool areOptionsInterestedInEvent_(
881 fpreal stopEvent_(
int event_id,
bool return_value);
885 void addToCumulativeFrameStats_(
886 fpreal frame_value,
bool is_memory_value);
889 void initDefaultColorRampScheme_();
892 int myActiveProfileId;
896 bool myDisplayNodeInfo;
915 mutable RWLock myEventsLock;
916 mutable RWLock myProfilesLock;
917 mutable RWLock myProfileInterestsLock;
918 mutable RWLock myEventInterestsLock;
953 fpreal myTotalFrameMemory;
954 int myTimedFrameEventCounter;
955 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.