HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_PerfMonAutoEvent.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_PerfMonAutoEvent.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  *
10  * Convenience classes for automatically starting and stopping
11  * timed and memory events in the Performance Monitor.
12  *
13  */
14 
15 #ifndef __UT_PerfMonAutoEvent__
16 #define __UT_PerfMonAutoEvent__
17 
18 #include "UT_NonCopyable.h"
19 #include "UT_Performance.h"
20 
21 class SIM_Solver;
22 
23 /// Base class.
24 /// Use one of the derived classes (below) instead.
26 {
27 public:
29  {
30  myTimedEventId = UT_PERFMON_INVALID_ID;
31  myMemoryEventId = UT_PERFMON_INVALID_ID;
32  myShouldStopEvents = true;
33  }
34 
36  {
37  if (!myShouldStopEvents)
38  return;
39 
40  if (myMemoryEventId != UT_PERFMON_INVALID_ID)
41  UTgetPerformance()->stopEvent(myMemoryEventId);
42  if (myTimedEventId != UT_PERFMON_INVALID_ID)
43  UTgetPerformance()->stopEvent(myTimedEventId);
44  }
45 
46  void setExtraInfo(const char *extra_info)
47  {
48  if (myTimedEventId != UT_PERFMON_INVALID_ID)
49  UTgetPerformance()->setEventExtraInfo(myTimedEventId, extra_info);
50 
51  if (myMemoryEventId != UT_PERFMON_INVALID_ID)
52  UTgetPerformance()->setEventExtraInfo(myMemoryEventId, extra_info);
53  }
54 
55  // These exist because the unit tests need them.
56  int getTimedEventId() const { return myTimedEventId; }
57  int getMemoryEventId() const { return myMemoryEventId; }
58 
59 protected:
60  void setTimedEventId_(int event_id) { myTimedEventId = event_id; }
61  void setMemoryEventId_(int event_id) { myMemoryEventId = event_id; }
62  void setShouldBaseClassStopEvents_(bool stop) { myShouldStopEvents = stop; }
63 
64 private:
65  int myTimedEventId;
66  int myMemoryEventId;
67  bool myShouldStopEvents;
68 };
69 
70 /// Convenience class for node cook events.
72 {
73 public:
74  UT_PerfMonAutoCookEvent(int node_id, const char *cook_event_name=NULL)
75  {
77 
78  /// The constructor's signature must match the signature
79  /// of UT_Performance::start*CookEvent().
80  if (perf->isRecordingCookStats())
81  {
83  perf->startTimedCookEvent(node_id, cook_event_name));
84  }
85 
86  if (perf->isRecordingMemoryStats())
87  {
89  perf->startMemoryCookEvent(node_id, cook_event_name));
90  }
91  }
93 };
94 
95 /// Convenience class for pdg cook events.
97 {
98 public:
100  const char *path, const char *pdg_event_name=NULL)
101  {
103 
104  /// The constructor's signature must match the signature
105  /// of UT_Performance::start*CookEvent().
106  if (perf->isRecordingPDGCookStats())
107  {
109  perf->startTimedPDGEvent(path, pdg_event_name));
110  }
111 
112  if (perf->isRecordingMemoryStats())
113  {
115  perf->startMemoryPDGEvent(path, pdg_event_name));
116  }
117  }
119 };
120 
121 /// Convenience class for DOP solve events.
123 {
124 public:
125  /// The constructor's signature must match the signature
126  /// of UT_Performance::start*SolveEvent().
128  const SIM_Solver *solver, const char *solver_event_name=NULL)
129  {
131 
132  if (perf->isRecordingSolveStats())
133  {
135  perf->startTimedSolveEvent(solver, solver_event_name));
136  }
137 
138  if (perf->isRecordingMemoryStats())
139  {
141  perf->startMemorySolveEvent(solver, solver_event_name));
142  }
143  }
145 };
146 
147 /// Convenience class for object draw events.
149 {
150 public:
151  /// The constructor's signature must match the signature
152  /// of UT_Performance::start*DrawEvent().
154  const char *object, const char *draw_event_name, bool is_gpu_draw=false)
155  {
157 
158  if ((!is_gpu_draw && perf->isRecordingObjectDrawStats())
159  || (is_gpu_draw && perf->isRecordingObjectGPUDrawStats()))
160  {
162  perf->startTimedDrawEvent(object, draw_event_name,
163  is_gpu_draw));
164  }
165 
166  if (perf->isRecordingMemoryStats())
167  {
169  perf->startMemoryDrawEvent(object, draw_event_name,
170  is_gpu_draw));
171  }
172  }
174 };
175 
176 /// Convenience class for viewport draw events.
178 {
179 public:
180  /// The constructor's signature must match the signature
181  /// of UT_Performance::start*DrawEvent().
183  const char *viewport_name, const char *draw_event_name,
184  UT_PerfMonViewportType viewport_type, bool is_gpu_draw=false)
185  {
187 
188  if (perf->isRecordingViewportStats())
189  {
192  viewport_name, draw_event_name, viewport_type,
193  is_gpu_draw));
194  }
195 
196  if (perf->isRecordingMemoryStats())
197  {
200  viewport_name, draw_event_name, viewport_type,
201  is_gpu_draw));
202  }
203  }
205 };
206 
207 /// Convenience class for script events.
209 {
210 public:
211  /// The constructor's signature must match the signature
212  /// of UT_Performance::start*ScriptEvent().
214  const char *code_description, UT_PerfMonScriptType script_type,
215  bool auto_nest_events=true)
216  {
218 
219  if (perf->isRecordingScriptStats())
220  {
222  perf->startTimedScriptEvent(
223  code_description, script_type, auto_nest_events));
224  }
225 
226  if (perf->isRecordingMemoryStats())
227  {
230  code_description, script_type, auto_nest_events));
231  }
232  }
234 };
235 
236 /// Convenience class for render events.
238 {
239 public:
240  /// The constructor's signature must match the signature
241  /// of UT_Performance::start*RenderEvent().
243  const char *renderer, const char *operation,
244  bool is_renderer_a_node, int frame_num, const char *object=NULL)
245  {
247 
248  if (perf->isRecordingRenderStats())
249  {
251  perf->startTimedRenderEvent(
252  renderer, operation, is_renderer_a_node,
253  frame_num, object));
254  }
255 
256  if (perf->isRecordingMemoryStats())
257  {
260  renderer, operation, is_renderer_a_node,
261  frame_num, object));
262  }
263  }
265 };
266 
267 /// Convenience class for node creation events.
269 {
270 public:
271  /// The constructor's signature must match the signature
272  /// of UT_Performance::start*NodeCreationEvent().
274  : myNodeId(-1)
275  , myRecording(false)
276  {
277  // Make sure that the base class does not attempt
278  // to stop the underlying events.
280 
282 
283  if (perf->isRecordingCookStats())
284  {
285  myRecording = true;
288  }
289 
290  if (perf->isRecordingMemoryStats())
291  {
292  myRecording = true;
295  }
296  }
298  {
300  {
302  getTimedEventId(), myNodeId);
303  }
305  {
307  getMemoryEventId(), myNodeId);
308  }
309  };
310 
311  /// Set the node id that should be attached to the underlying
312  /// node creation events. This method should be called
313  /// immediately after the node is created.
314  void setNodeId(int node_id) { myNodeId = node_id; }
315 
316  bool isRecording() const { return myRecording; }
317 
318 private:
319  int myNodeId;
320  bool myRecording;
321 };
322 
323 /// Convenience class for pane events.
325 {
326 public:
327  /// The constructor's signature must match the signature
328  /// of UT_Performance::startTimedPaneEvent().
330  const char *panetype, const char *operation)
331  {
333 
334  if (perf->isRecordingScriptStats())
335  {
337  perf->startTimedPaneEvent(panetype, operation));
338  }
339 
340  if (perf->isRecordingMemoryStats())
341  {
343  perf->startMemoryPaneEvent(panetype, operation));
344  }
345  }
347 };
348 
349 
350 #endif
351 
UT_PerfMonAutoCookEvent(int node_id, const char *cook_event_name=NULL)
int startMemoryPDGEvent(const char *path, const char *pdg_event_name=NULL)
UT_API UT_Performance * UTgetPerformance(bool create=true)
Convenience class for object draw events.
UT_PerfMonAutoPaneEvent(const char *panetype, const char *operation)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
int getMemoryEventId() const
void stopNodeCreationEvent(int event_id, int node_id)
int startTimedViewportDrawEvent(const char *viewport_name, const char *draw_event_name, UT_PerfMonViewportType viewport_type, bool is_gpu_draw=false)
int startTimedRenderEvent(const char *renderer, const char *operation, bool is_renderer_a_node, int frame_num, const char *object=NULL)
UT_PerfMonAutoScriptEvent(const char *code_description, UT_PerfMonScriptType script_type, bool auto_nest_events=true)
bool isRecordingRenderStats() const
Return true if Houdini is recording render stats.
int startTimedPDGEvent(const char *path, const char *pdg_event_name=NULL)
bool isRecordingSolveStats() const
Return true if Houdini is recording simulation solve stats.
UT_PerfMonAutoViewportDrawEvent(const char *viewport_name, const char *draw_event_name, UT_PerfMonViewportType viewport_type, bool is_gpu_draw=false)
int startMemorySolveEvent(const SIM_Solver *solver, const char *solver_event_name=NULL)
bool isRecordingMemoryStats() const
Return true if Houdini is recording memory stats.
void setMemoryEventId_(int event_id)
int startTimedScriptEvent(const char *code_description, UT_PerfMonScriptType script_type, bool auto_nest_events=true)
Convenience class for pdg cook events.
bool isRecordingCookStats() const
Return true if Houdini is recording cook stats.
UT_PerfMonAutoPDGCookEvent(const char *path, const char *pdg_event_name=NULL)
Convenience class for DOP solve events.
int startTimedCookEvent(int node_id, const char *cook_event_name=NULL)
bool isRecordingScriptStats() const
Return true if Houdini is recording script stats.
int startTimedDrawEvent(const char *object, const char *draw_event_name, bool is_gpu_draw=false)
Convenience class for viewport draw events.
Convenience class for render events.
bool isRecordingViewportStats() const
Return true if Houdini is recording viewport draw stats.
Convenience class for node creation events.
Convenience class for node cook events.
int startMemoryRenderEvent(const char *renderer, const char *operation, bool is_renderer_a_node, int frame_num, const char *object=NULL)
UT_PerfMonAutoSolveEvent(const SIM_Solver *solver, const char *solver_event_name=NULL)
void setExtraInfo(const char *extra_info)
#define UT_PERFMON_INVALID_ID
fpreal stopEvent(int event_id, bool return_value=false)
UT_PerfMonViewportType
Viewport types recognized by the performance monitor.
Convenience class for pane events.
void setTimedEventId_(int event_id)
UT_PerfMonAutoDrawEvent(const char *object, const char *draw_event_name, bool is_gpu_draw=false)
bool isRecordingObjectDrawStats() const
Return true if Houdini is recording object draw stats.
Convenience class for script events.
int startMemoryNodeCreationEvent()
bool isRecordingObjectGPUDrawStats() const
Return true if Houdini is recording object draw stats.
bool isRecordingPDGCookStats() const
Return true if Houdini is recording pdg cook stats.
int startMemoryScriptEvent(const char *code_description, UT_PerfMonScriptType script_type, bool auto_nest_events=true)
UT_PerfMonScriptType
Script types recognized by the performance monitor.
int startMemoryPaneEvent(const char *pane, const char *operation)
int startTimedSolveEvent(const SIM_Solver *solver, const char *solver_event_name=NULL)
int startMemoryCookEvent(int node_id, const char *cook_event_name=NULL)
void setEventExtraInfo(int event_id, const char *extra_info) const
int startTimedNodeCreationEvent()
void setShouldBaseClassStopEvents_(bool stop)
UT_PerfMonAutoRenderEvent(const char *renderer, const char *operation, bool is_renderer_a_node, int frame_num, const char *object=NULL)
int startTimedPaneEvent(const char *pane, const char *operation)
Start a timed geometry spreadsheet render event.
int getTimedEventId() const
int startMemoryDrawEvent(const char *object, const char *draw_event_name, bool is_gpu_draw=false)
int startMemoryViewportDrawEvent(const char *viewport_name, const char *draw_event_name, UT_PerfMonViewportType viewport_type, bool is_gpu_draw=false)