mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 06:21:26 +12:00
std::chrono cleanup: always use steady_clock
This commit is contained in:
parent
12a48fc6d1
commit
aa3aef4beb
19 changed files with 96 additions and 97 deletions
|
@ -8,8 +8,8 @@ class Timer
|
|||
{
|
||||
private:
|
||||
bool m_stopped;
|
||||
std::chrono::steady_clock::time_point m_start;
|
||||
std::chrono::steady_clock::time_point m_end;
|
||||
steady_clock::time_point m_start;
|
||||
steady_clock::time_point m_end;
|
||||
|
||||
public:
|
||||
Timer() : m_stopped(false)
|
||||
|
@ -19,13 +19,13 @@ public:
|
|||
void Start()
|
||||
{
|
||||
m_stopped = false;
|
||||
m_start = std::chrono::steady_clock::now();
|
||||
m_start = steady_clock::now();
|
||||
}
|
||||
|
||||
void Stop()
|
||||
{
|
||||
m_stopped = true;
|
||||
m_end = std::chrono::steady_clock::now();
|
||||
m_end = steady_clock::now();
|
||||
}
|
||||
|
||||
double GetElapsedTimeInSec() const
|
||||
|
@ -40,21 +40,21 @@ public:
|
|||
|
||||
u64 GetElapsedTimeInMicroSec() const
|
||||
{
|
||||
std::chrono::steady_clock::time_point now = m_stopped ? m_end : std::chrono::steady_clock::now();
|
||||
steady_clock::time_point now = m_stopped ? m_end : steady_clock::now();
|
||||
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>(now - m_start).count();
|
||||
}
|
||||
|
||||
u64 GetElapsedTimeInNanoSec() const
|
||||
{
|
||||
std::chrono::steady_clock::time_point now = m_stopped ? m_end : std::chrono::steady_clock::now();
|
||||
steady_clock::time_point now = m_stopped ? m_end : steady_clock::now();
|
||||
|
||||
return std::chrono::duration_cast<std::chrono::nanoseconds>(now - m_start).count();
|
||||
}
|
||||
|
||||
u64 GetMsSince(std::chrono::steady_clock::time_point timestamp)
|
||||
u64 GetMsSince(steady_clock::time_point timestamp)
|
||||
{
|
||||
std::chrono::steady_clock::time_point now = m_stopped ? m_end : std::chrono::steady_clock::now();
|
||||
steady_clock::time_point now = m_stopped ? m_end : steady_clock::now();
|
||||
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(now - timestamp).count();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
#include <limits>
|
||||
#include <array>
|
||||
|
||||
using std::chrono::steady_clock;
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if !defined(__cpp_lib_bitops) && _MSC_VER < 1928
|
||||
#define __cpp_lib_bitops
|
||||
|
@ -43,9 +47,6 @@
|
|||
#define CHECK_MAX_SIZE(type, size) static_assert(sizeof(type) <= size, #type " type size is too big")
|
||||
#define CHECK_SIZE_ALIGN(type, size, align) CHECK_SIZE(type, size); CHECK_ALIGN(type, align)
|
||||
|
||||
// Variant pattern matching helper
|
||||
#define MATCH(arg, ...) constexpr(std::is_same_v<std::decay_t<decltype(arg)>, __VA_ARGS__>)
|
||||
|
||||
#define DECLARE(...) decltype(__VA_ARGS__) __VA_ARGS__
|
||||
|
||||
#define STR_CASE(...) case __VA_ARGS__: return #__VA_ARGS__
|
||||
|
@ -149,10 +150,6 @@ namespace std
|
|||
}
|
||||
#endif
|
||||
|
||||
using steady_clock = std::conditional<
|
||||
std::chrono::high_resolution_clock::is_steady,
|
||||
std::chrono::high_resolution_clock, std::chrono::steady_clock>::type;
|
||||
|
||||
// Get integral type from type size
|
||||
template <std::size_t N>
|
||||
struct get_int_impl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue