TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Stopwatch.h
Go to the documentation of this file.
1 
13 #ifndef G3D_Stopwatch_h
14 #define G3D_Stopwatch_h
15 
16 #include "G3D/platform.h"
17 #include "G3D/Queue.h"
18 #include "G3D/G3DGameUnits.h"
19 #include "G3D/g3dmath.h"
20 
21 namespace G3D {
22 
45 class Stopwatch {
46 private:
47 
48  std::string myName;
49 
50  bool m_enabled;
51 
52  double startTime;
53  std::string prevMark;
54  double prevTime;
55 
57  bool inBetween;
58 
61 
64 
67 
70 
72  double m_fps;
73 
75  double emwaFPS;
76  double m_smoothFPS;
77 
80 
83 
85  void computeOverhead();
86 
87 public:
88 
89  Stopwatch(const std::string& name = "Stopwatch");
90 
91  void setEnabled(bool e) {
92  m_enabled = e;
93  }
94 
96  bool enabled() const {
97  return m_enabled;
98  }
99 
102  double FPS() const {
103  return m_fps;
104  }
105 
109  return lastDuration;
110  }
111 
116  return emwaDuration;
117  }
118 
123  double smoothFPS() const {
124  return m_smoothFPS;
125  }
126 
131  return lastCycleCount;
132  }
133 
135  void tick();
136 
138  void tock();
139 
140 
142  void reset();
143 
149  void after(const std::string& s = "");
150 
151 };
152 
155 
156 }
157 
158 #endif
159 
RealTime elapsedTime() const
Definition: Stopwatch.h:108
Stopwatch StopWatch
Definition: Stopwatch.h:154
RealTime lastDuration
Definition: Stopwatch.h:68
double emwaFPS
Definition: Stopwatch.h:75
RealTime timeStart
Definition: Stopwatch.h:63
void computeOverhead()
Definition: Stopwatch.cpp:28
bool m_enabled
Definition: Stopwatch.h:50
Definition: AABox.h:25
std::string prevMark
Definition: Stopwatch.h:53
uint64_t uint64
Definition: g3dmath.h:170
RealTime emwaDuration
Definition: Stopwatch.h:79
double RealTime
Definition: G3DGameUnits.h:27
void tick()
Definition: Stopwatch.cpp:36
double startTime
Definition: Stopwatch.h:52
uint64 elapsedCycles() const
Definition: Stopwatch.h:130
void reset()
Definition: Stopwatch.cpp:100
double m_smoothFPS
Definition: Stopwatch.h:76
double prevTime
Definition: Stopwatch.h:54
double smoothFPS() const
Definition: Stopwatch.h:123
Accurately measure durations and framerates.
Definition: Stopwatch.h:45
void after(const std::string &s="")
Definition: Stopwatch.cpp:106
std::string myName
Definition: Stopwatch.h:48
void tock()
Definition: Stopwatch.cpp:49
bool enabled() const
Definition: Stopwatch.h:96
double m_fps
Definition: Stopwatch.h:72
RealTime lastTockTime
Definition: Stopwatch.h:66
int64_t int64
Definition: g3dmath.h:169
int64 cycleOverhead
Definition: Stopwatch.h:82
void setEnabled(bool e)
Definition: Stopwatch.h:91
bool inBetween
Definition: Stopwatch.h:57
Stopwatch(const std::string &name="Stopwatch")
Definition: Stopwatch.cpp:18
int64 lastCycleCount
Definition: Stopwatch.h:69
double FPS() const
Definition: Stopwatch.h:102
uint64 cycleStart
Definition: Stopwatch.h:60
RealTime smoothElapsedTime() const
Definition: Stopwatch.h:115