HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_OldPerformance.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_OldPerformance.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  *
10  * The old performance monitor (< H12).
11  *
12  */
13 
14 #ifndef __UT_OldPerformance__
15 #define __UT_OldPerformance__
16 
17 #include "UT_API.h"
18 
19 #include <SYS/SYS_Time.h>
20 #include "UT_Lock.h"
21 #include "UT_ValArray.h"
22 #include "UT_FloatArray.h"
23 #include "UT_ThreadSpecificValue.h"
24 #include "UT_WorkBuffer.h"
25 
26 enum {
27  LOG_OFF = 0,
30 };
31 
32 enum {
36 };
37 
38 enum {
41  PERFORMANCE_WINDOW_LOG_HIGH = 2 // Important message to be highlighted.
42 };
43 
45 {
47  UT_PERF_FILTER_HIGHLIGHT, // Highlight long ops
48  UT_PERF_FILTER_HIDE // Hide short ops
49 };
50 
52  int type, void *data, const char *msg, int refresh);
53 
54 class utPerfEvent;
55 class ut_Perf;
56 
58 {
59 public:
61  virtual ~UT_OldPerformance();
62 
63  ///
64  /// Methods to log performance events. These methods are recorded on
65  /// a per thread basis
66  ///
67  // @{
68  void startEvent(int thread,
69  const char *type,
70  const char *name = 0,
71  const char *info = 0,
72  int count = -1);
73  fpreal stopEvent(int thread, bool log = true);
74 
75  /// This allows one to manually add to the accumulated time.
76  void logAccumulatedTime(int thread, fpreal time_ms);
77 
78  // @}
79 
80  void logMessage(const char *m, int refresh = 1,
81  fpreal dtime = -1,
82  const utPerfEvent *event = 0);
83 
84  void filterLog(UT_OldPerformanceFilter filter,
85  fpreal time_threshold_ms);
86 
87  void logEnable(int yesno)
88  {
89  if( myLogEnable )
90  frameComplete(myLastFrame);
91  myLogEnable = yesno;
92  myFrameState = 0;
93  }
94  int logEnabled() const
95  { return myLogEnable && myLogType; }
96 
97  int opTiming() const
98  {
99  return
100  (myOpInfo || myOpHighlight ||
101  (myLogEnable && myLogType && myLogCookTime));
102  }
103 
104  int frameTiming() const
105  {
106  return logEnabled() && myLogFLength;
107  }
108 
110  {
111  myFunc = func;
112  myData = data;
113  }
114 
115  ///
116  /// frame methods
117  ///
118  /// @{
119 
120  /// frameChange is for automatically timing a series of frames.
121  /// it stops timing the previous frame and starts timing the given one
122  void frameChange(fpreal frame);
123 
124  /// use frameStart and frameComplete for single-frame timing
125  void frameStart(fpreal frame);
126  void frameComplete(fpreal frame);
127  fpreal getLastFrame() const { return myLastFrame; }
128 
129  /// @}
130 
131  ///
132  /// op methods
133  ///
134  /// @{
135 
136  int opInfo() const { return myOpInfo; }
137  void opInfo(int yesno) { myOpInfo = yesno; }
138 
139  int opHighlight() const { return myOpHighlight; }
140  void opHighlight(int yesno) { myOpHighlight = yesno; }
141 
142  /// @}
143 
144  ///
145  /// memory methods
146  ///
147  /// @{
148  void startMemoryLog();
149  void stopMemoryLog(const char *label);
150  /// @}
151 
152  ///
153  /// log query methods
154  ///
155  /// @{
156 
157  int logType() const { return myLogType; }
158  void logType(int type);
159  void logPause(int yesno);
160  void logSorted(int yesno);
161 
162  int logTimeFormat() const { return myTimeFormat; }
163  void logTimeFormat( int format ) { myTimeFormat = format; }
164 
165  int logCookTime() const
166  { return logEnabled() && myLogCookTime; }
167  void logCookTime(int yesno)
168  { myLogCookTime = yesno; }
169 
170  bool logSolveTime() const
171  { return logEnabled() && myLogSolveTime; }
172  void logSolveTime(bool enable)
173  { myLogSolveTime = enable; }
174 
175  int logLongCHOPs() const
176  { return logEnabled() && myLogLongCHOPs; }
177  void logLongCHOPs(int yesno)
178  { myLogLongCHOPs = yesno; }
179 
180  int logObjectViewTime() const
181  { return logEnabled() && myLogObjectViewTime; }
182  void logObjectViewTime(int yesno)
183  { myLogObjectViewTime = yesno; }
184 
185  int logViewPortTime() const
186  { return logEnabled() && myLogViewPortTime; }
187  void logViewPortTime(int yesno)
188  { myLogViewPortTime = yesno; }
189 
190  int logFLength() const
191  { return logEnabled() && myLogFLength; }
192  void logFLength(int yesno)
193  { myLogFLength = yesno; }
194 
195  int logMemory() const
196  { return logEnabled() && myLogMemory; }
197  void logMemory(int yesno)
198  { myLogMemory = yesno; }
199 
200  int logErrors() const
201  { return logEnabled() && myLogErrors; }
202  void logErrors(int yesno)
203  { myLogErrors = yesno; }
204 
206  { myFrameCount = 0; myFrameTotal = 0.0; }
207 
208  /// @}
209 
210  //
211  // misc
212  //
213  // @{
214  static void formatTime(UT_WorkBuffer &buf, fpreal t,
215  const char *prefix,
216  const char *suffix = "\n\r",
217  int format = TIME_FORMAT_ALL);
218  // @}
219 
220 private:
221 
222  /// Option that determines whether performance information is displayed
223  /// with Node info.
224 // bool myDisplayNodeInfo;
225 
226  // decomposition of frameChange
227  void logFrameAverage();
228  void clearAccumTime();
229  void startFrame(fpreal frame);
230  void endFrame(fpreal dtime);
231  fpreal elapsedTime(SYS_TimeVal &etime);
232 
233  int myLogType;
234  int myTimeFormat;
235  int myFrameState;
236 
237  unsigned int myLogEnable : 1,
238 
239  myOpInfo : 1,
240  myOpHighlight : 1,
241 
242  myLogPause : 1,
243  myLogSorted : 1,
244  myLogCookTime : 1,
245  myLogLongCHOPs : 1,
246  myLogViewPortTime : 1,
247  myLogObjectViewTime : 1,
248  myLogFLength : 1,
249  myLogMemory : 1,
250  myLogErrors : 1,
251  myLogSolveTime : 1;
252 
253  void appendMessage(const char *m, fpreal dtime,
254  const utPerfEvent *event);
255 
256  void clearMessages();
257  void flushMessages();
258 
259 
260  UT_ValArray<char *> myMessage;
261  UT_ValArray<utPerfEvent *> myMessageEvent;
262  UT_FloatArray myMessageTime;
263  int myMessageCount;
264 
265  UT_OldPerformanceCB myFunc;
266  void *myData;
267 
268  int myFrameCount;
269  fpreal myFrameTotal;
270 
271  size_t myMemoryUsage;
272 
274 
275  fpreal myLastFrame;
276  SYS_TimeVal myStartTime;
277 
278  /// am i currently timing a frame?
279  bool myTiming;
280 
281  UT_OldPerformanceFilter myFilter;
282  fpreal myFilterThreshold;
283  int myFilterHiddenEvents;
284 
285  UT_Lock myLock;
286 };
287 
288 UT_API UT_OldPerformance *UTgetOldPerformance(bool create=true);
290 
291 #endif
292 
struct timeval SYS_TimeVal
Definition: SYS_Time.h:27
int opTiming() const
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
void logCookTime(int yesno)
void logFLength(int yesno)
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
void logViewPortTime(int yesno)
void logEnable(int yesno)
int logMemory() const
int logFLength() const
#define UT_API
Definition: UT_API.h:13
fpreal getLastFrame() const
void opInfo(int yesno)
void opHighlight(int yesno)
void logSolveTime(bool enable)
struct _cl_event * event
Definition: glcorearb.h:2960
int frameTiming() const
SYS_API double log(double x)
Definition: SYS_FPUMath.h:87
int logViewPortTime() const
void logMemory(int yesno)
void setCallback(UT_OldPerformanceCB func, void *data)
int logTimeFormat() const
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
void logErrors(int yesno)
int logErrors() const
GLint GLsizei count
Definition: glcorearb.h:404
void logLongCHOPs(int yesno)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2539
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:107
double fpreal
Definition: SYS_Types.h:270
GLenum func
Definition: glcorearb.h:782
UT_OldPerformanceFilter
int logCookTime() const
void logTimeFormat(int format)
UT_API void UTsetOldPerformance(UT_OldPerformance *perfmon)
int logLongCHOPs() const
int logEnabled() const
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
bool logSolveTime() const
void logObjectViewTime(int yesno)
UT_API UT_OldPerformance * UTgetOldPerformance(bool create=true)
int opHighlight() const
int logObjectViewTime() const
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1296
void(* UT_OldPerformanceCB)(int type, void *data, const char *msg, int refresh)