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