HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_CumulativeTimer.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_CumulativeTimer.h ( UT Library, C++)
7  *
8  * Measures the amount of time between start() and stop() calls,
9  * accumulating the time in a threadsafe manner.
10  */
11 #ifndef UT_CumulativeTimer_H
12 #define UT_CumulativeTimer_H
13 
14 #include "UT_String.h"
15 #include "UT_SpinLock.h"
16 #include "UT_StopWatch.h"
17 #include "UT_ThreadSpecificValue.h"
18 
19 
21 {
22 public:
23  UT_CumulativeTimer(const char *name, bool report_on_destroy = false);
25 
26  // Print the time when this object is destroyed if true.
27  void reportWhenDestroyed(bool report = true);
28 
29  // Start and stop the timer. Can be used safely in multiple threads
30  // simultaneously.
31  void start();
32  void stop();
33 
34  // Reset accumulated time to zero.
35  void reset();
36 
37  const char *getName() const;
38 
39  // Total time between all threads.
40  double getTime() const;
41 
42  // Time when more than one thread is timing at once.
43  double getOverlapTime() const;
44 
45  // Wall clock time, from the time the first thread starts, til the time
46  // the last ends.
47  double getTotalTime() const;
48 
49 private:
50  UT_String myName;
51 
52  // Per-thread timing state.
55  UT_StopWatch myOverlapTimer;
56  UT_StopWatch myTotalTimer;
57 
58  // A spin lock is used because the critical sections are extremely short.
59  UT_SpinLock myLock;
60 
61  // Total time for all threads
62  double myTime;
63  double myOverlapTime;
64  double myTotalTime;
65  int myTimingCount;
66  bool myReportOnDestroy;
67 };
68 
69 
70 #endif
GLuint start
Definition: glcorearb.h:475
#define UT_API
Definition: UT_API.h:14
GLboolean reset
Definition: glad.h:5138
PXL_API const char * getName(const ColorSpace *space)
Return the name of the color space.
GLuint const GLchar * name
Definition: glcorearb.h:786