mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-02 21:11:25 +12:00
This commit is contained in:
parent
de070bf485
commit
a90b5cf37a
1998 changed files with 1034301 additions and 0 deletions
47
Utilities/Timer.h
Normal file
47
Utilities/Timer.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
#pragma once
|
||||
|
||||
class Timer
|
||||
{
|
||||
private:
|
||||
bool stopped;
|
||||
double startTimeInMicroSec;
|
||||
double endTimeInMicroSec;
|
||||
LARGE_INTEGER frequency;
|
||||
LARGE_INTEGER startCycle;
|
||||
LARGE_INTEGER endCycle;
|
||||
|
||||
public:
|
||||
Timer()
|
||||
{
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
startCycle.QuadPart = 0;
|
||||
endCycle.QuadPart = 0;
|
||||
stopped = false;
|
||||
startTimeInMicroSec = 0;
|
||||
endTimeInMicroSec = 0;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
stopped = false;
|
||||
QueryPerformanceCounter(&startCycle);
|
||||
}
|
||||
|
||||
void Stop()
|
||||
{
|
||||
stopped = true;
|
||||
QueryPerformanceCounter(&endCycle);
|
||||
}
|
||||
|
||||
double GetElapsedTimeInSec(){return GetElapsedTimeInMicroSec() / 1000000.0;}
|
||||
double GetElapsedTimeInMilliSec(){return GetElapsedTimeInMicroSec() / 1000.0;}
|
||||
double GetElapsedTimeInMicroSec()
|
||||
{
|
||||
if(!stopped) QueryPerformanceCounter(&endCycle);
|
||||
|
||||
startTimeInMicroSec = startCycle.QuadPart * (1000000.0 / frequency.QuadPart);
|
||||
endTimeInMicroSec = endCycle.QuadPart * (1000000.0 / frequency.QuadPart);
|
||||
|
||||
return endTimeInMicroSec - startTimeInMicroSec;
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue