MCPcopy Create free account
hub / github.com/cemu-project/Cemu / HighResolutionTimer

Class HighResolutionTimer

src/util/highresolutiontimer/HighResolutionTimer.h:5–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using HRTick = uint64;
4
5class HighResolutionTimer
6{
7public:
8 HighResolutionTimer()
9 {
10 m_timePoint = 0;
11 }
12
13 HRTick getTick() const
14 {
15 return m_timePoint;
16 }
17
18 uint64 getTickInSeconds() const
19 {
20 return m_timePoint / m_freq;
21 }
22
23 // return time difference in seconds, this is an utility function mainly intended for debugging/benchmarking purposes. Avoid using doubles for precise timing
24 static double getTimeDiff(HRTick startTime, HRTick endTime)
25 {
26 return (double)(endTime - startTime) / (double)m_freq;
27 }
28
29 // returns tick difference and frequency
30 static uint64 getTimeDiffEx(HRTick startTime, HRTick endTime, uint64& freq)
31 {
32 freq = m_freq;
33 return endTime - startTime;
34 }
35
36 static HighResolutionTimer now();
37 static HRTick getFrequency();
38
39 static HRTick microsecondsToTicks(uint64 microseconds)
40 {
41 return microseconds * m_freq / 1000000;
42 }
43
44 static uint64 ticksToMicroseconds(HRTick ticks)
45 {
46 return ticks * 1000000 / m_freq;
47 }
48
49private:
50 HighResolutionTimer(uint64 timePoint) : m_timePoint(timePoint) {};
51
52 uint64 m_timePoint;
53 static uint64 m_freq;
54};
55
56// benchmark helper utility
57// measures time between Start() and Stop() call

Calls

no outgoing calls

Tested by

no test coverage detected