summaryrefslogtreecommitdiffstats
path: root/src/common/wall_clock.h
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2020-02-09 21:53:22 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2020-06-18 22:29:17 +0200
commit234b5ff6a999d7d69cdcdf214e0c3984cdab11cf (patch)
tree4f0ef41d7738b53d1b81ac2f7072bec1ba5fe8f1 /src/common/wall_clock.h
parentTests: Add base tests to host timing (diff)
downloadyuzu-234b5ff6a999d7d69cdcdf214e0c3984cdab11cf.tar
yuzu-234b5ff6a999d7d69cdcdf214e0c3984cdab11cf.tar.gz
yuzu-234b5ff6a999d7d69cdcdf214e0c3984cdab11cf.tar.bz2
yuzu-234b5ff6a999d7d69cdcdf214e0c3984cdab11cf.tar.lz
yuzu-234b5ff6a999d7d69cdcdf214e0c3984cdab11cf.tar.xz
yuzu-234b5ff6a999d7d69cdcdf214e0c3984cdab11cf.tar.zst
yuzu-234b5ff6a999d7d69cdcdf214e0c3984cdab11cf.zip
Diffstat (limited to 'src/common/wall_clock.h')
-rw-r--r--src/common/wall_clock.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h
new file mode 100644
index 000000000..6f763d74b
--- /dev/null
+++ b/src/common/wall_clock.h
@@ -0,0 +1,40 @@
+// Copyright 2020 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <chrono>
+
+#include "common/common_types.h"
+
+namespace Common {
+
+class WallClock {
+public:
+ virtual std::chrono::nanoseconds GetTimeNS() = 0;
+ virtual std::chrono::microseconds GetTimeUS() = 0;
+ virtual std::chrono::milliseconds GetTimeMS() = 0;
+ virtual u64 GetClockCycles() = 0;
+ virtual u64 GetCPUCycles() = 0;
+
+ /// Tells if the wall clock, uses the host CPU's hardware clock
+ bool IsNative() const {
+ return is_native;
+ }
+
+protected:
+ WallClock(u64 emulated_cpu_frequency, u64 emulated_clock_frequency, bool is_native)
+ : emulated_cpu_frequency{emulated_cpu_frequency},
+ emulated_clock_frequency{emulated_clock_frequency}, is_native{is_native} {}
+
+ u64 emulated_cpu_frequency;
+ u64 emulated_clock_frequency;
+
+private:
+ bool is_native;
+};
+
+WallClock* CreateBestMatchingClock(u32 emulated_cpu_frequency, u32 emulated_clock_frequency);
+
+} // namespace Common