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 
47 
48  void setExtraInfo(const char *extra_info)
49  {
50  if (myTimedEventId != UT_PERFMON_INVALID_ID)
51  UTgetPerformance()->setEventExtraInfo(myTimedEventId, extra_info);
52 
53  if (myMemoryEventId != UT_PERFMON_INVALID_ID)
54  UTgetPerformance()->setEventExtraInfo(myMemoryEventId, extra_info);
55  }
56 
57  // These exist because the unit tests need them.
58  int getTimedEventId() const { return myTimedEventId; }
59  int getMemoryEventId() const { return myMemoryEventId; }
60 
61 protected:
62  void setTimedEventId_(int event_id) { myTimedEventId = event_id; }
63  void setMemoryEventId_(int event_id) { myMemoryEventId = event_id; }
64  void setShouldBaseClassStopEvents_(bool stop) { myShouldStopEvents = stop; }
65 
66 private:
67  int myTimedEventId;
68  int myMemoryEventId;
69  bool myShouldStopEvents;
70 };
71 
72 /// Convenience class for general events.
74 {
75 public:
76  UT_PerfMonAutoGeneralEvent(const char *event, const char *object)
77  {
79 
81  perf->startTimedEvent(event, object));
82 
83  if (perf->isRecordingMemoryStats())
84  {
86  perf->startMemoryEvent(object));
87  }
88  }
90 };
91 
92 /// Convenience class for node cook events.
94 {
95 public:
97  int node_id,
98  const char *cook_event_name = nullptr,
99  bool profile_recording_only = false)
100  {
102 
103  /// The constructor's signature must match the signature
104  /// of UT_Performance::start*CookEvent().
105  if (perf->isRecordingCookStats(profile_recording_only))
106  {
108  perf->startTimedCookEvent(node_id, cook_event_name));
109  }
110 
111  if (perf->isRecordingMemoryStats())
112  {
114  perf->startMemoryCookEvent(node_id, cook_event_name));
115  }
116  }
118 };
119 
120 /// Convenience class for pdg cook events.
122 {
123 public:
125  const char *path, const char *pdg_event_name=NULL)
126  {
128 
129  /// The constructor's signature must match the signature
130  /// of UT_Performance::start*CookEvent().
131  if (perf->isRecordingPDGCookStats())
132  {
134  perf->startTimedPDGEvent(path, pdg_event_name));
135  }
136 
137  if (perf->isRecordingMemoryStats())
138  {
140  perf->startMemoryPDGEvent(path, pdg_event_name));
141  }
142  }
144 };
145 
146 /// Convenience class for DOP solve events.
148 {
149 public:
150  /// The constructor's signature must match the signature
151  /// of UT_Performance::start*SolveEvent().
153  const SIM_Solver *solver, const char *solver_event_name=NULL)
154  {
156 
157  if (perf->isRecordingSolveStats())
158  {
160  perf->startTimedSolveEvent(solver, solver_event_name));
161  }
162 
163  if (perf->isRecordingMemoryStats())
164  {
166  perf->startMemorySolveEvent(solver, solver_event_name));
167  }
168  }
170 };
171 
172 /// Convenience class for object draw events.
174 {
175 public:
176  /// The constructor's signature must match the signature
177  /// of UT_Performance::start*DrawEvent().
179  const char *object, const char *draw_event_name, bool is_gpu_draw=false)
180  {
182 
183  if ((!is_gpu_draw && perf->isRecordingObjectDrawStats())
184  || (is_gpu_draw && perf->isRecordingObjectGPUDrawStats()))
185  {
187  perf->startTimedDrawEvent(object, draw_event_name,
188  is_gpu_draw));
189  }
190 
191  if (perf->isRecordingMemoryStats())
192  {
194  perf->startMemoryDrawEvent(object, draw_event_name,
195  is_gpu_draw));
196  }
197  }
199 };
200 
201 /// Convenience class for viewport draw events.
203 {
204 public:
205  /// The constructor's signature must match the signature
206  /// of UT_Performance::start*DrawEvent().
208  const char *viewport_name, const char *draw_event_name,
209  UT_PerfMonViewportType viewport_type, bool is_gpu_draw=false)
210  {
212 
213  if (perf->isRecordingViewportStats())
214  {
217  viewport_name, draw_event_name, viewport_type,
218  is_gpu_draw));
219  }
220 
221  if (perf->isRecordingMemoryStats())
222  {
225  viewport_name, draw_event_name, viewport_type,
226  is_gpu_draw));
227  }
228  }
230 };
231 
232 /// Convenience class for script events.
234 {
235 public:
236  /// The constructor's signature must match the signature
237  /// of UT_Performance::start*ScriptEvent().
239  const char *code_description, UT_PerfMonScriptType script_type,
240  bool auto_nest_events=true)
241  {
243 
244  if (perf->isRecordingScriptStats())
245  {
247  perf->startTimedScriptEvent(
248  code_description, script_type, auto_nest_events));
249  }
250 
251  if (perf->isRecordingMemoryStats())
252  {
255  code_description, script_type, auto_nest_events));
256  }
257  }
259 };
260 
261 /// Convenience class for HAPI events.
263 {
264 public:
266  const char *code_description, bool auto_nest_events=true)
268  code_description, UT_PERFMON_HAPI, auto_nest_events)
269  {
270  }
272 };
273 
274 /// Convenience class for script events tied to nodes.
276 {
277 public:
278  /// The constructor's signature must match the signature
279  /// of UT_Performance::start*ScriptEvent().
281  int node_id, const char *code_description,
282  UT_PerfMonScriptType script_type)
283  {
285 
286  if (perf->isRecordingScriptStats())
287  {
290  node_id, code_description, script_type));
291  }
292 
293  if (perf->isRecordingMemoryStats())
294  {
297  node_id, code_description, script_type));
298  }
299  }
301 };
302 
303 /// Convenience class for render events.
305 {
306 public:
307  /// The constructor's signature must match the signature
308  /// of UT_Performance::start*RenderEvent().
310  const char *renderer, const char *operation,
311  bool is_renderer_a_node, int frame_num, const char *object=NULL)
312  {
314 
315  if (perf->isRecordingRenderStats())
316  {
318  perf->startTimedRenderEvent(
319  renderer, operation, is_renderer_a_node,
320  frame_num, object));
321  }
322 
323  if (perf->isRecordingMemoryStats())
324  {
327  renderer, operation, is_renderer_a_node,
328  frame_num, object));
329  }
330  }
332 };
333 
334 /// Convenience class for node creation events.
336 {
337 public:
338  /// The constructor's signature must match the signature
339  /// of UT_Performance::start*NodeCreationEvent().
341  : myNodeId(-1)
342  , myRecording(false)
343  {
344  // Make sure that the base class does not attempt
345  // to stop the underlying events.
347 
349 
350  if (perf->isRecordingCookStats())
351  {
352  myRecording = true;
355  }
356 
357  if (perf->isRecordingMemoryStats())
358  {
359  myRecording = true;
362  }
363  }
365  {
367  {
369  getTimedEventId(), myNodeId);
370  }
372  {
374  getMemoryEventId(), myNodeId);
375  }
376  };
377 
378  /// Set the node id that should be attached to the underlying
379  /// node creation events. This method should be called
380  /// immediately after the node is created.
381  void setNodeId(int node_id) { myNodeId = node_id; }
382 
383  bool isRecording() const { return myRecording; }
384 
385 private:
386  int myNodeId;
387  bool myRecording;
388 };
389 
390 /// Convenience class for pane events.
392 {
393 public:
394  /// The constructor's signature must match the signature
395  /// of UT_Performance::startTimedPaneEvent().
397  const char *panetype, const char *operation)
398  {
400 
401  if (perf->isRecordingScriptStats())
402  {
404  perf->startTimedPaneEvent(panetype, operation));
405  }
406 
407  if (perf->isRecordingMemoryStats())
408  {
410  perf->startMemoryPaneEvent(panetype, operation));
411  }
412  }
414 };
415 
416 
417 #endif
418 
int startTimedEvent(const char *event, const char *object, bool auto_nest_events=true)
UT_PerfMonAutoCookEvent(int node_id, const char *cook_event_name=nullptr, bool profile_recording_only=false)
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.
void
Definition: png.h:1083
UT_PerfMonAutoPaneEvent(const char *panetype, const char *operation)
UT_PerfMonAutoNodeScriptEvent(int node_id, const char *code_description, UT_PerfMonScriptType script_type)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
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)
int startMemoryNodeScriptEvent(int node_id, const char *code_description, UT_PerfMonScriptType script_type)
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.
struct _cl_event * event
Definition: glcorearb.h:2961
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 general events.
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.
int startTimedNodeScriptEvent(int node_id, const char *code_description, UT_PerfMonScriptType script_type)
Convenience class for node cook events.
UT_PerfMonAutoHAPIEvent(const char *code_description, bool auto_nest_events=true)
int startMemoryRenderEvent(const char *renderer, const char *operation, bool is_renderer_a_node, int frame_num, const char *object=NULL)
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
bool isRecordingCookStats(bool profile_only=false) const
Return true if Houdini is recording cook stats.
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 HAPI events.
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 startMemoryEvent(const char *object, bool auto_nest_events=true)
int startTimedNodeCreationEvent()
Convenience class for script events tied to nodes.
void setShouldBaseClassStopEvents_(bool stop)
UT_PerfMonAutoRenderEvent(const char *renderer, const char *operation, bool is_renderer_a_node, int frame_num, const char *object=NULL)
UT_PerfMonAutoGeneralEvent(const char *event, const char *object)
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)