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 script events tied to nodes.
263 {
264 public:
265  /// The constructor's signature must match the signature
266  /// of UT_Performance::start*ScriptEvent().
268  int node_id, const char *code_description,
269  UT_PerfMonScriptType script_type)
270  {
272 
273  if (perf->isRecordingScriptStats())
274  {
277  node_id, code_description, script_type));
278  }
279 
280  if (perf->isRecordingMemoryStats())
281  {
284  node_id, code_description, script_type));
285  }
286  }
288 };
289 
290 /// Convenience class for render events.
292 {
293 public:
294  /// The constructor's signature must match the signature
295  /// of UT_Performance::start*RenderEvent().
297  const char *renderer, const char *operation,
298  bool is_renderer_a_node, int frame_num, const char *object=NULL)
299  {
301 
302  if (perf->isRecordingRenderStats())
303  {
305  perf->startTimedRenderEvent(
306  renderer, operation, is_renderer_a_node,
307  frame_num, object));
308  }
309 
310  if (perf->isRecordingMemoryStats())
311  {
314  renderer, operation, is_renderer_a_node,
315  frame_num, object));
316  }
317  }
319 };
320 
321 /// Convenience class for node creation events.
323 {
324 public:
325  /// The constructor's signature must match the signature
326  /// of UT_Performance::start*NodeCreationEvent().
328  : myNodeId(-1)
329  , myRecording(false)
330  {
331  // Make sure that the base class does not attempt
332  // to stop the underlying events.
334 
336 
337  if (perf->isRecordingCookStats())
338  {
339  myRecording = true;
342  }
343 
344  if (perf->isRecordingMemoryStats())
345  {
346  myRecording = true;
349  }
350  }
352  {
354  {
356  getTimedEventId(), myNodeId);
357  }
359  {
361  getMemoryEventId(), myNodeId);
362  }
363  };
364 
365  /// Set the node id that should be attached to the underlying
366  /// node creation events. This method should be called
367  /// immediately after the node is created.
368  void setNodeId(int node_id) { myNodeId = node_id; }
369 
370  bool isRecording() const { return myRecording; }
371 
372 private:
373  int myNodeId;
374  bool myRecording;
375 };
376 
377 /// Convenience class for pane events.
379 {
380 public:
381  /// The constructor's signature must match the signature
382  /// of UT_Performance::startTimedPaneEvent().
384  const char *panetype, const char *operation)
385  {
387 
388  if (perf->isRecordingScriptStats())
389  {
391  perf->startTimedPaneEvent(panetype, operation));
392  }
393 
394  if (perf->isRecordingMemoryStats())
395  {
397  perf->startMemoryPaneEvent(panetype, operation));
398  }
399  }
401 };
402 
403 
404 #endif
405 
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.
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 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)
#define const
Definition: zconf.h:214
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)