From 4e766280c4481d23a64a1c80c0ec40d7cf1ff378 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Sun, 30 Jan 2022 12:36:56 -0500 Subject: common: wall_clock: Utilize constants for ms, us, and ns ratios --- src/common/wall_clock.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/common/wall_clock.h') diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h index cef3e9499..4d132c531 100644 --- a/src/common/wall_clock.h +++ b/src/common/wall_clock.h @@ -13,6 +13,10 @@ namespace Common { class WallClock { public: + static constexpr u64 NS_RATIO = 1'000'000'000; + static constexpr u64 US_RATIO = 1'000'000; + static constexpr u64 MS_RATIO = 1'000; + virtual ~WallClock() = default; /// Returns current wall time in nanoseconds -- cgit v1.2.3 From 6267110b694d3b3f8a8561c61ad6b4a4548873b5 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Sun, 30 Jan 2022 12:57:23 -0500 Subject: common: wall_clock: Check precision against the emulated CPU and CNTFRQ In addition to requiring nanosecond precision, using the native clock requires that the hardware TSC has a precision greater than the emulated CPU and its clock counter. --- src/common/wall_clock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common/wall_clock.h') diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h index 4d132c531..874448c27 100644 --- a/src/common/wall_clock.h +++ b/src/common/wall_clock.h @@ -53,7 +53,7 @@ private: bool is_native; }; -[[nodiscard]] std::unique_ptr CreateBestMatchingClock(u32 emulated_cpu_frequency, - u32 emulated_clock_frequency); +[[nodiscard]] std::unique_ptr CreateBestMatchingClock(u64 emulated_cpu_frequency, + u64 emulated_clock_frequency); } // namespace Common -- cgit v1.2.3