Common: Refactor & Document Wall clock.

This commit is contained in:
Fernando Sahmkow 2020-02-10 11:20:40 -04:00
parent 234b5ff6a9
commit e3524d1142
6 changed files with 50 additions and 51 deletions

View file

@ -5,6 +5,7 @@
#pragma once
#include <chrono>
#include <memory>
#include "common/common_types.h"
@ -12,10 +13,20 @@ namespace Common {
class WallClock {
public:
/// Returns current wall time in nanoseconds
virtual std::chrono::nanoseconds GetTimeNS() = 0;
/// Returns current wall time in microseconds
virtual std::chrono::microseconds GetTimeUS() = 0;
/// Returns current wall time in milliseconds
virtual std::chrono::milliseconds GetTimeMS() = 0;
/// Returns current wall time in emulated clock cycles
virtual u64 GetClockCycles() = 0;
/// Returns current wall time in emulated cpu cycles
virtual u64 GetCPUCycles() = 0;
/// Tells if the wall clock, uses the host CPU's hardware clock
@ -35,6 +46,6 @@ private:
bool is_native;
};
WallClock* CreateBestMatchingClock(u32 emulated_cpu_frequency, u32 emulated_clock_frequency);
std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, u32 emulated_clock_frequency);
} // namespace Common