diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/wall_clock.cpp | 4 | ||||
| -rw-r--r-- | src/common/wall_clock.h | 2 | ||||
| -rw-r--r-- | src/common/x64/native_clock.cpp | 7 | ||||
| -rw-r--r-- | src/common/x64/native_clock.h | 2 |
4 files changed, 15 insertions, 0 deletions
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp index d4d35f4e7..a46db6bbf 100644 --- a/src/common/wall_clock.cpp +++ b/src/common/wall_clock.cpp | |||
| @@ -53,6 +53,10 @@ public: | |||
| 53 | return Common::Divide128On32(temporary, 1000000000).first; | 53 | return Common::Divide128On32(temporary, 1000000000).first; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | void Pause(bool is_paused) override { | ||
| 57 | // Do nothing in this clock type. | ||
| 58 | } | ||
| 59 | |||
| 56 | private: | 60 | private: |
| 57 | base_time_point start_time; | 61 | base_time_point start_time; |
| 58 | }; | 62 | }; |
diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h index ed284cf50..367d72134 100644 --- a/src/common/wall_clock.h +++ b/src/common/wall_clock.h | |||
| @@ -28,6 +28,8 @@ public: | |||
| 28 | /// Returns current wall time in emulated cpu cycles | 28 | /// Returns current wall time in emulated cpu cycles |
| 29 | virtual u64 GetCPUCycles() = 0; | 29 | virtual u64 GetCPUCycles() = 0; |
| 30 | 30 | ||
| 31 | virtual void Pause(bool is_paused) = 0; | ||
| 32 | |||
| 31 | /// Tells if the wall clock, uses the host CPU's hardware clock | 33 | /// Tells if the wall clock, uses the host CPU's hardware clock |
| 32 | bool IsNative() const { | 34 | bool IsNative() const { |
| 33 | return is_native; | 35 | return is_native; |
diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index 26d4d0ba6..926f92ff8 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp | |||
| @@ -65,6 +65,13 @@ u64 NativeClock::GetRTSC() { | |||
| 65 | return accumulated_ticks; | 65 | return accumulated_ticks; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | void NativeClock::Pause(bool is_paused) { | ||
| 69 | if (!is_paused) { | ||
| 70 | _mm_mfence(); | ||
| 71 | last_measure = __rdtsc(); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 68 | std::chrono::nanoseconds NativeClock::GetTimeNS() { | 75 | std::chrono::nanoseconds NativeClock::GetTimeNS() { |
| 69 | const u64 rtsc_value = GetRTSC(); | 76 | const u64 rtsc_value = GetRTSC(); |
| 70 | return std::chrono::nanoseconds{MultiplyAndDivide64(rtsc_value, 1000000000, rtsc_frequency)}; | 77 | return std::chrono::nanoseconds{MultiplyAndDivide64(rtsc_value, 1000000000, rtsc_frequency)}; |
diff --git a/src/common/x64/native_clock.h b/src/common/x64/native_clock.h index b58cf9f5a..3851f8fc2 100644 --- a/src/common/x64/native_clock.h +++ b/src/common/x64/native_clock.h | |||
| @@ -26,6 +26,8 @@ public: | |||
| 26 | 26 | ||
| 27 | u64 GetCPUCycles() override; | 27 | u64 GetCPUCycles() override; |
| 28 | 28 | ||
| 29 | void Pause(bool is_paused) override; | ||
| 30 | |||
| 29 | private: | 31 | private: |
| 30 | u64 GetRTSC(); | 32 | u64 GetRTSC(); |
| 31 | 33 | ||