summaryrefslogtreecommitdiffstats
path: root/src/common/wall_clock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/wall_clock.cpp')
-rw-r--r--src/common/wall_clock.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp
index 012fdc1e0..e14bf3e65 100644
--- a/src/common/wall_clock.cpp
+++ b/src/common/wall_clock.cpp
@@ -18,42 +18,40 @@ namespace Common {
class StandardWallClock final : public WallClock {
public:
- explicit StandardWallClock() : start_time{SteadyClock::Now()} {}
+ explicit StandardWallClock() {}
std::chrono::nanoseconds GetTimeNS() const override {
- return SteadyClock::Now() - start_time;
+ return std::chrono::duration_cast<std::chrono::nanoseconds>(
+ std::chrono::system_clock::now().time_since_epoch());
}
std::chrono::microseconds GetTimeUS() const override {
- return static_cast<std::chrono::microseconds>(GetHostTicksElapsed() / NsToUsRatio::den);
+ return std::chrono::duration_cast<std::chrono::microseconds>(
+ std::chrono::system_clock::now().time_since_epoch());
}
std::chrono::milliseconds GetTimeMS() const override {
- return static_cast<std::chrono::milliseconds>(GetHostTicksElapsed() / NsToMsRatio::den);
+ return std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::system_clock::now().time_since_epoch());
}
- u64 GetCNTPCT() const override {
- return GetHostTicksElapsed() * NsToCNTPCTRatio::num / NsToCNTPCTRatio::den;
+ s64 GetCNTPCT() const override {
+ return GetUptime() * NsToCNTPCTRatio::num / NsToCNTPCTRatio::den;
}
- u64 GetGPUTick() const override {
- return GetHostTicksElapsed() * NsToGPUTickRatio::num / NsToGPUTickRatio::den;
+ s64 GetGPUTick() const override {
+ return GetUptime() * NsToGPUTickRatio::num / NsToGPUTickRatio::den;
}
- u64 GetHostTicksNow() const override {
- return static_cast<u64>(SteadyClock::Now().time_since_epoch().count());
- }
-
- u64 GetHostTicksElapsed() const override {
- return static_cast<u64>(GetTimeNS().count());
+ s64 GetUptime() const override {
+ return std::chrono::duration_cast<std::chrono::nanoseconds>(
+ std::chrono::steady_clock::now().time_since_epoch())
+ .count();
}
bool IsNative() const override {
return false;
}
-
-private:
- SteadyClock::time_point start_time;
};
std::unique_ptr<WallClock> CreateOptimalClock() {