diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2023-03-01 19:17:50 -0500 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2023-03-05 01:41:19 -0500 |
commit | bd09c825218aac9255643b9aa7c75f5ba156038c (patch) | |
tree | 76a7fb4a83ec09a927767d9f8c8a3342107c67cd /src/common/steady_clock.h | |
parent | ce8f4da63834be0179d98a7720dee47d65f3ec06 (diff) |
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.
Diffstat (limited to 'src/common/steady_clock.h')
-rw-r--r-- | src/common/steady_clock.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/common/steady_clock.h b/src/common/steady_clock.h new file mode 100644 index 000000000..9497cf865 --- /dev/null +++ b/src/common/steady_clock.h @@ -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 |