summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Timer.h
diff options
context:
space:
mode:
authorShawn Hoffman <godisgovernment@gmail.com>2022-07-17 20:43:47 -0700
committerShawn Hoffman <godisgovernment@gmail.com>2022-08-02 22:24:06 -0700
commit09089eeee0bf6022cc7681214e51546d134402ea (patch)
tree8a209216e224f8a28c1217459769efba6499a2fb /Source/Core/Common/Timer.h
parent8d16971a6fcd3534c9dd34d625c151d2a5ce3ed9 (diff)
Common::Timer: use chrono::steady_clock internally
Diffstat (limited to 'Source/Core/Common/Timer.h')
-rw-r--r--Source/Core/Common/Timer.h41
1 files changed, 17 insertions, 24 deletions
diff --git a/Source/Core/Common/Timer.h b/Source/Core/Common/Timer.h
index 614e7b3dfe..160f3a23c9 100644
--- a/Source/Core/Common/Timer.h
+++ b/Source/Core/Common/Timer.h
@@ -11,43 +11,36 @@ namespace Common
class Timer
{
public:
- Timer();
+ static u64 NowUs();
+ static u64 NowMs();
void Start();
+ // Start(), then decrement start time by the offset.
+ // Effectively "resumes" a timer
+ void StartWithOffset(u64 offset);
void Stop();
- void Update();
+ bool IsRunning() const { return m_running; }
+ u64 ElapsedMs() const;
- // The time difference is always returned in milliseconds, regardless of alternative internal
- // representation
- u64 GetTimeDifference();
- void AddTimeDifference();
+ static u64 GetLocalTimeSinceJan1970();
- bool IsRunning() const { return m_Running; }
+ // Returns biased system timestamp as double
+ // It is very unlikely you want to use this in new code; ideally we can remove it completely.
+ static double GetSystemTimeAsDouble();
+ // Formats a timestamp from GetSystemTimeAsDouble() into a date and time string
+ static std::string SystemTimeAsDoubleToString(double time);
static void IncreaseResolution();
static void RestoreResolution();
- static u64 GetTimeSinceJan1970();
- static u64 GetLocalTimeSinceJan1970();
- // Returns a timestamp with decimals for precise time comparisons
- static double GetDoubleTime();
-
- static std::string GetTimeFormatted();
- // Formats a timestamp from GetDoubleTime() into a date and time string
- static std::string GetDateTimeFormatted(double time);
- std::string GetTimeElapsedFormatted() const;
- u64 GetTimeElapsed();
-
- static u32 GetTimeMs();
- static u64 GetTimeUs();
- // Arbitrarily chosen value (38 years) that is subtracted in GetDoubleTime()
+ // Arbitrarily chosen value (38 years) that is subtracted in GetSystemTimeAsDouble()
// to increase sub-second precision of the resulting double timestamp
static constexpr int DOUBLE_TIME_OFFSET = (38 * 365 * 24 * 60 * 60);
private:
- u64 m_LastTime;
- u64 m_StartTime;
- bool m_Running;
+ u64 m_start_ms{0};
+ u64 m_end_ms{0};
+ bool m_running{false};
};
} // Namespace Common