diff options
author | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2023-10-29 14:50:55 +0100 |
---|---|---|
committer | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2024-01-24 05:26:55 +0100 |
commit | e4915fb7d2077584a11a15141bc81d28ed2b0125 (patch) | |
tree | 1783055dc2e98eaf9099e8e7b194b55f8f607747 /src/common/wall_clock.cpp | |
parent | Merge pull request #12678 from german77/settings_impl (diff) | |
download | yuzu-e4915fb7d2077584a11a15141bc81d28ed2b0125.tar yuzu-e4915fb7d2077584a11a15141bc81d28ed2b0125.tar.gz yuzu-e4915fb7d2077584a11a15141bc81d28ed2b0125.tar.bz2 yuzu-e4915fb7d2077584a11a15141bc81d28ed2b0125.tar.lz yuzu-e4915fb7d2077584a11a15141bc81d28ed2b0125.tar.xz yuzu-e4915fb7d2077584a11a15141bc81d28ed2b0125.tar.zst yuzu-e4915fb7d2077584a11a15141bc81d28ed2b0125.zip |
Diffstat (limited to 'src/common/wall_clock.cpp')
-rw-r--r-- | src/common/wall_clock.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp index 012fdc1e0..e14bf3e65 100644 --- a/src/common/wall_clock.cpp +++ b/src/common/wall_clock.cpp @@ -18,42 +18,40 @@ namespace Common { class StandardWallClock final : public WallClock { public: - explicit StandardWallClock() : start_time{SteadyClock::Now()} {} + explicit StandardWallClock() {} std::chrono::nanoseconds GetTimeNS() const override { - return SteadyClock::Now() - start_time; + return std::chrono::duration_cast<std::chrono::nanoseconds>( + std::chrono::system_clock::now().time_since_epoch()); } std::chrono::microseconds GetTimeUS() const override { - return static_cast<std::chrono::microseconds>(GetHostTicksElapsed() / NsToUsRatio::den); + return std::chrono::duration_cast<std::chrono::microseconds>( + std::chrono::system_clock::now().time_since_epoch()); } std::chrono::milliseconds GetTimeMS() const override { - return static_cast<std::chrono::milliseconds>(GetHostTicksElapsed() / NsToMsRatio::den); + return std::chrono::duration_cast<std::chrono::milliseconds>( + std::chrono::system_clock::now().time_since_epoch()); } - u64 GetCNTPCT() const override { - return GetHostTicksElapsed() * NsToCNTPCTRatio::num / NsToCNTPCTRatio::den; + s64 GetCNTPCT() const override { + return GetUptime() * NsToCNTPCTRatio::num / NsToCNTPCTRatio::den; } - u64 GetGPUTick() const override { - return GetHostTicksElapsed() * NsToGPUTickRatio::num / NsToGPUTickRatio::den; + s64 GetGPUTick() const override { + return GetUptime() * NsToGPUTickRatio::num / NsToGPUTickRatio::den; } - u64 GetHostTicksNow() const override { - return static_cast<u64>(SteadyClock::Now().time_since_epoch().count()); - } - - u64 GetHostTicksElapsed() const override { - return static_cast<u64>(GetTimeNS().count()); + s64 GetUptime() const override { + return std::chrono::duration_cast<std::chrono::nanoseconds>( + std::chrono::steady_clock::now().time_since_epoch()) + .count(); } bool IsNative() const override { return false; } - -private: - SteadyClock::time_point start_time; }; std::unique_ptr<WallClock> CreateOptimalClock() { |