aboutsummaryrefslogtreecommitdiff
path: root/src/core/core_timing.h
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2023-03-01 21:06:19 -0500
committerMorph <39850852+Morph1984@users.noreply.github.com>2023-03-05 02:36:31 -0500
commitbff14532825e7517882ca913738347059f73cf7f (patch)
treef21f509d4c7458a79e2fc399c1de3036a7efd51d /src/core/core_timing.h
parent7e353082ac79bef59d48602f9196cf804d3dfc4f (diff)
core_timing: Use higher precision sleeps on Windows
The precision of sleep_for and wait_for is limited to 1-1.5ms on Windows. Using SleepForOneTick() allows us to sleep for exactly one interval of the current timer resolution. This allows us to take advantage of systems that have a timer resolution of 0.5ms to reduce CPU overhead in the event loop.
Diffstat (limited to 'src/core/core_timing.h')
-rw-r--r--src/core/core_timing.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/core_timing.h b/src/core/core_timing.h
index da366637b..4b89c0c39 100644
--- a/src/core/core_timing.h
+++ b/src/core/core_timing.h
@@ -122,6 +122,9 @@ public:
/// Returns current time in emulated in Clock cycles
u64 GetClockTicks() const;
+ /// Returns current time in nanoseconds.
+ std::chrono::nanoseconds GetCPUTimeNs() const;
+
/// Returns current time in microseconds.
std::chrono::microseconds GetGlobalTimeUs() const;
@@ -139,7 +142,8 @@ private:
void Reset();
- std::unique_ptr<Common::WallClock> clock;
+ std::unique_ptr<Common::WallClock> cpu_clock;
+ std::unique_ptr<Common::WallClock> event_clock;
s64 global_timer = 0;