HostTiming: Pause the hardware clock on pause.
This commit is contained in:
parent
6bf137a0e8
commit
18dcb09342
7 changed files with 23 additions and 1 deletions
|
@ -53,6 +53,10 @@ public:
|
|||
return Common::Divide128On32(temporary, 1000000000).first;
|
||||
}
|
||||
|
||||
void Pause(bool is_paused) override {
|
||||
// Do nothing in this clock type.
|
||||
}
|
||||
|
||||
private:
|
||||
base_time_point start_time;
|
||||
};
|
||||
|
|
|
@ -28,6 +28,8 @@ public:
|
|||
/// Returns current wall time in emulated cpu cycles
|
||||
virtual u64 GetCPUCycles() = 0;
|
||||
|
||||
virtual void Pause(bool is_paused) = 0;
|
||||
|
||||
/// Tells if the wall clock, uses the host CPU's hardware clock
|
||||
bool IsNative() const {
|
||||
return is_native;
|
||||
|
|
|
@ -65,6 +65,13 @@ u64 NativeClock::GetRTSC() {
|
|||
return accumulated_ticks;
|
||||
}
|
||||
|
||||
void NativeClock::Pause(bool is_paused) {
|
||||
if (!is_paused) {
|
||||
_mm_mfence();
|
||||
last_measure = __rdtsc();
|
||||
}
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds NativeClock::GetTimeNS() {
|
||||
const u64 rtsc_value = GetRTSC();
|
||||
return std::chrono::nanoseconds{MultiplyAndDivide64(rtsc_value, 1000000000, rtsc_frequency)};
|
||||
|
|
|
@ -26,6 +26,8 @@ public:
|
|||
|
||||
u64 GetCPUCycles() override;
|
||||
|
||||
void Pause(bool is_paused) override;
|
||||
|
||||
private:
|
||||
u64 GetRTSC();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue