summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2023-03-02 01:43:00 +0100
committerMorph <39850852+Morph1984@users.noreply.github.com>2023-03-05 08:36:31 +0100
commit7fffdf83b70ec5f0ead804cb2c16b9029f7e0cfa (patch)
tree7444e4f15fb5a7b49004d1bca34779545dab3ce0 /src
parentcommon: Implement a method to change the Windows timer resolution (diff)
downloadyuzu-7fffdf83b70ec5f0ead804cb2c16b9029f7e0cfa.tar
yuzu-7fffdf83b70ec5f0ead804cb2c16b9029f7e0cfa.tar.gz
yuzu-7fffdf83b70ec5f0ead804cb2c16b9029f7e0cfa.tar.bz2
yuzu-7fffdf83b70ec5f0ead804cb2c16b9029f7e0cfa.tar.lz
yuzu-7fffdf83b70ec5f0ead804cb2c16b9029f7e0cfa.tar.xz
yuzu-7fffdf83b70ec5f0ead804cb2c16b9029f7e0cfa.tar.zst
yuzu-7fffdf83b70ec5f0ead804cb2c16b9029f7e0cfa.zip
Diffstat (limited to 'src')
-rw-r--r--src/common/wall_clock.cpp34
1 files changed, 11 insertions, 23 deletions
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp
index ae07f2811..6d972d136 100644
--- a/src/common/wall_clock.cpp
+++ b/src/common/wall_clock.cpp
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include "common/steady_clock.h"
#include "common/uint128.h"
#include "common/wall_clock.h"
@@ -11,45 +12,32 @@
namespace Common {
-using base_timer = std::chrono::steady_clock;
-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) {
- start_time = base_timer::now();
- }
+ : WallClock{emulated_cpu_frequency_, emulated_clock_frequency_, false},
+ start_time{SteadyClock::Now()} {}
std::chrono::nanoseconds GetTimeNS() override {
- base_time_point current = base_timer::now();
- auto elapsed = current - start_time;
- return std::chrono::duration_cast<std::chrono::nanoseconds>(elapsed);
+ return SteadyClock::Now() - start_time;
}
std::chrono::microseconds GetTimeUS() override {
- base_time_point current = base_timer::now();
- auto elapsed = current - start_time;
- return std::chrono::duration_cast<std::chrono::microseconds>(elapsed);
+ return std::chrono::duration_cast<std::chrono::microseconds>(GetTimeNS());
}
std::chrono::milliseconds GetTimeMS() override {
- base_time_point current = base_timer::now();
- auto elapsed = current - start_time;
- return std::chrono::duration_cast<std::chrono::milliseconds>(elapsed);
+ return std::chrono::duration_cast<std::chrono::milliseconds>(GetTimeNS());
}
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;
+ const u128 temp = Common::Multiply64Into128(GetTimeNS().count(), emulated_clock_frequency);
+ return Common::Divide128On32(temp, NS_RATIO).first;
}
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;
+ const u128 temp = Common::Multiply64Into128(GetTimeNS().count(), emulated_cpu_frequency);
+ return Common::Divide128On32(temp, NS_RATIO).first;
}
void Pause([[maybe_unused]] bool is_paused) override {
@@ -57,7 +45,7 @@ public:
}
private:
- base_time_point start_time;
+ SteadyClock::time_point start_time;
};
#ifdef ARCHITECTURE_x86_64