mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 17:11:23 +00:00
321d323beb
- Implemended vfsDir. - Improved vfsDevice. - Improved vfsFile.
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <chrono>
|
|
|
|
class Timer
|
|
{
|
|
private:
|
|
bool m_stopped;
|
|
std::chrono::high_resolution_clock::time_point m_start;
|
|
std::chrono::high_resolution_clock::time_point m_end;
|
|
|
|
public:
|
|
Timer() : m_stopped(false)
|
|
{
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
m_stopped = false;
|
|
m_start = std::chrono::high_resolution_clock::now();
|
|
}
|
|
|
|
void Stop()
|
|
{
|
|
m_stopped = true;
|
|
m_end = std::chrono::high_resolution_clock::now();
|
|
}
|
|
|
|
double GetElapsedTimeInSec() const
|
|
{
|
|
return GetElapsedTimeInMicroSec() / 1000000.0;
|
|
}
|
|
|
|
double GetElapsedTimeInMilliSec() const
|
|
{
|
|
return GetElapsedTimeInMicroSec() / 1000.0;
|
|
}
|
|
|
|
double GetElapsedTimeInMicroSec() const
|
|
{
|
|
std::chrono::high_resolution_clock::time_point now = m_stopped ? m_end : std::chrono::high_resolution_clock::now();
|
|
|
|
return std::chrono::duration_cast<std::chrono::microseconds>(now - m_start).count();
|
|
}
|
|
|
|
double GetElapsedTimeInNanoSec() const
|
|
{
|
|
std::chrono::high_resolution_clock::time_point now = m_stopped ? m_end : std::chrono::high_resolution_clock::now();
|
|
|
|
return std::chrono::duration_cast<std::chrono::nanoseconds>(now - m_start).count();
|
|
}
|
|
};
|