From 762b8ad448369cc770beae4d8368a6258b13709e Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 2 Dec 2021 14:20:43 -0500 Subject: general: Replace high_resolution_clock with steady_clock On some OSes, high_resolution_clock is an alias to system_clock and is not monotonic in nature. Replace this with steady_clock. --- src/common/x64/native_clock.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/common/x64/native_clock.cpp') diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index 87de40624..28f834443 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp @@ -19,16 +19,16 @@ u64 EstimateRDTSCFrequency() { // get current time _mm_mfence(); const u64 tscStart = __rdtsc(); - const auto startTime = std::chrono::high_resolution_clock::now(); + const auto startTime = std::chrono::steady_clock::now(); // wait roughly 3 seconds while (true) { auto milli = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now() - startTime); + std::chrono::steady_clock::now() - startTime); if (milli.count() >= 3000) break; std::this_thread::sleep_for(milli_10); } - const auto endTime = std::chrono::high_resolution_clock::now(); + const auto endTime = std::chrono::steady_clock::now(); _mm_mfence(); const u64 tscEnd = __rdtsc(); // calculate difference -- cgit v1.2.3