common: Implement a high resolution steady clock

This implementation provides a consistent, high performance, and high resolution clock where/when std::chrono::steady_clock does not provide sufficient precision.
This commit is contained in:
Morph 2023-03-01 19:17:50 -05:00
parent ce8f4da638
commit bd09c82521
3 changed files with 81 additions and 0 deletions

23
src/common/steady_clock.h Normal file
View file

@ -0,0 +1,23 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <chrono>
#include "common/common_types.h"
namespace Common {
struct SteadyClock {
using rep = s64;
using period = std::nano;
using duration = std::chrono::nanoseconds;
using time_point = std::chrono::time_point<SteadyClock>;
static constexpr bool is_steady = true;
[[nodiscard]] static time_point Now() noexcept;
};
} // namespace Common