diff options
author | bunnei <bunneidev@gmail.com> | 2021-02-16 22:17:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-16 22:17:22 +0100 |
commit | 6be0975bf279e1fd1eed356b84e10b116447694d (patch) | |
tree | 0db0b3b8d41c56b089d23c4f1f1b85c7f52ae6e1 /src/common/wall_clock.cpp | |
parent | Merge pull request #5929 from german77/mousePanning (diff) | |
parent | core: core_timing_util: Optimize core timing math. (diff) | |
download | yuzu-6be0975bf279e1fd1eed356b84e10b116447694d.tar yuzu-6be0975bf279e1fd1eed356b84e10b116447694d.tar.gz yuzu-6be0975bf279e1fd1eed356b84e10b116447694d.tar.bz2 yuzu-6be0975bf279e1fd1eed356b84e10b116447694d.tar.lz yuzu-6be0975bf279e1fd1eed356b84e10b116447694d.tar.xz yuzu-6be0975bf279e1fd1eed356b84e10b116447694d.tar.zst yuzu-6be0975bf279e1fd1eed356b84e10b116447694d.zip |
Diffstat (limited to 'src/common/wall_clock.cpp')
-rw-r--r-- | src/common/wall_clock.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp index a8c143f85..1545993bd 100644 --- a/src/common/wall_clock.cpp +++ b/src/common/wall_clock.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <cstdint> + #include "common/uint128.h" #include "common/wall_clock.h" @@ -18,7 +20,9 @@ using base_time_point = std::chrono::time_point<base_timer>; class StandardWallClock final : public WallClock { public: explicit StandardWallClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequency_) - : WallClock(emulated_cpu_frequency_, emulated_clock_frequency_, false) { + : WallClock(emulated_cpu_frequency_, emulated_clock_frequency_, false), + emulated_clock_factor{GetFixedPoint64Factor(emulated_clock_frequency, 1000000000)}, + emulated_cpu_factor{GetFixedPoint64Factor(emulated_cpu_frequency, 1000000000)} { start_time = base_timer::now(); } @@ -41,16 +45,11 @@ public: } u64 GetClockCycles() override { - std::chrono::nanoseconds time_now = GetTimeNS(); - const u128 temporary = - Common::Multiply64Into128(time_now.count(), emulated_clock_frequency); - return Common::Divide128On32(temporary, 1000000000).first; + return MultiplyHigh(GetTimeNS().count(), emulated_clock_factor); } u64 GetCPUCycles() override { - std::chrono::nanoseconds time_now = GetTimeNS(); - const u128 temporary = Common::Multiply64Into128(time_now.count(), emulated_cpu_frequency); - return Common::Divide128On32(temporary, 1000000000).first; + return MultiplyHigh(GetTimeNS().count(), emulated_cpu_factor); } void Pause([[maybe_unused]] bool is_paused) override { @@ -59,6 +58,8 @@ public: private: base_time_point start_time; + const u64 emulated_clock_factor; + const u64 emulated_cpu_factor; }; #ifdef ARCHITECTURE_x86_64 |