wavelength 1.0.0
Loading...
Searching...
No Matches
Timer.h
Go to the documentation of this file.
1#pragma once
2
8extern unsigned int gLastCycleCount;
9
15extern unsigned int gDeltaCycles;
16
22extern int gCalibrateCount;
23
29extern float gMsPerCycle;
30
36extern unsigned __int64 gTotalCycles;
37
39inline unsigned int ReadTimeStampCounter() {
40 unsigned int low;
41 __asm {
42 push edx
43 push eax
44 _emit 0x0f // rdtsc
45 _emit 0x31
46 mov low, eax
47 pop eax
48 pop edx
49 }
50 return low;
51}
52
58inline float TimerUpdateMs() {
59 if (gCalibrateCount == 1) {
60 const unsigned int cycles = ReadTimeStampCounter();
62 gLastCycleCount = cycles;
63 }
65 return static_cast<float>(static_cast<__int64>(gTotalCycles)) * gMsPerCycle;
66}
67
74class Timer {
75public:
78
79 int mReserved00; // +0x00, not set by the constructor and not yet identified.
80 int mReserved04; // +0x04, cleared by the constructor and not yet identified.
81 int mReserved08; // +0x08, cleared by the constructor and not yet identified.
82 const char *mName;
83 int mReserved10; // +0x10, cleared by the constructor and not yet identified.
84};
float gMsPerCycle
The milliseconds of one cycle of the time-stamp counter.
unsigned __int64 gTotalCycles
The cycles counted since the timer started.
unsigned int ReadTimeStampCounter()
Definition Timer.h:39
unsigned int gDeltaCycles
The cycles between the last two readings.
float TimerUpdateMs()
Add the cycles since the last reading to the total.
Definition Timer.h:58
unsigned int gLastCycleCount
The time-stamp counter at the last reading.
int gCalibrateCount
1 once the counter is calibrated and read at every update.
Stopwatch on the EE cycle counter.
Definition timer.h:16
int mReserved00
Definition Timer.h:79
Timer()
Definition Timer.h:76
int mReserved08
Definition Timer.h:81
int mReserved10
Definition Timer.h:83
int mReserved04
Definition Timer.h:80