diff options
Diffstat (limited to 'src/common/wall_clock.h')
| -rw-r--r-- | src/common/wall_clock.h | 40 |
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 @@ | |||
| 1 | // Copyright 2020 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <chrono> | ||
| 8 | |||
| 9 | #include "common/common_types.h" | ||
| 10 | |||
| 11 | namespace Common { | ||
| 12 | |||
| 13 | class WallClock { | ||
| 14 | public: | ||
| 15 | virtual std::chrono::nanoseconds GetTimeNS() = 0; | ||
| 16 | virtual std::chrono::microseconds GetTimeUS() = 0; | ||
| 17 | virtual std::chrono::milliseconds GetTimeMS() = 0; | ||
| 18 | virtual u64 GetClockCycles() = 0; | ||
| 19 | virtual u64 GetCPUCycles() = 0; | ||
| 20 | |||
| 21 | /// Tells if the wall clock, uses the host CPU's hardware clock | ||
| 22 | bool IsNative() const { | ||
| 23 | return is_native; | ||
| 24 | } | ||
| 25 | |||
| 26 | protected: | ||
| 27 | WallClock(u64 emulated_cpu_frequency, u64 emulated_clock_frequency, bool is_native) | ||
| 28 | : emulated_cpu_frequency{emulated_cpu_frequency}, | ||
| 29 | emulated_clock_frequency{emulated_clock_frequency}, is_native{is_native} {} | ||
| 30 | |||
| 31 | u64 emulated_cpu_frequency; | ||
| 32 | u64 emulated_clock_frequency; | ||
| 33 | |||
| 34 | private: | ||
| 35 | bool is_native; | ||
| 36 | }; | ||
| 37 | |||
| 38 | WallClock* CreateBestMatchingClock(u32 emulated_cpu_frequency, u32 emulated_clock_frequency); | ||
| 39 | |||
| 40 | } // namespace Common | ||