diff options
| author | 2023-03-01 19:17:50 -0500 | |
|---|---|---|
| committer | 2023-03-05 01:41:19 -0500 | |
| commit | bd09c825218aac9255643b9aa7c75f5ba156038c (patch) | |
| tree | 76a7fb4a83ec09a927767d9f8c8a3342107c67cd /src/common/steady_clock.h | |
| parent | Merge pull request #9884 from liamwhite/service-cleanup (diff) | |
| download | yuzu-bd09c825218aac9255643b9aa7c75f5ba156038c.tar.gz yuzu-bd09c825218aac9255643b9aa7c75f5ba156038c.tar.xz yuzu-bd09c825218aac9255643b9aa7c75f5ba156038c.zip | |
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 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <chrono> | ||
| 7 | |||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 10 | namespace Common { | ||
| 11 | |||
| 12 | struct SteadyClock { | ||
| 13 | using rep = s64; | ||
| 14 | using period = std::nano; | ||
| 15 | using duration = std::chrono::nanoseconds; | ||
| 16 | using time_point = std::chrono::time_point<SteadyClock>; | ||
| 17 | |||
| 18 | static constexpr bool is_steady = true; | ||
| 19 | |||
| 20 | [[nodiscard]] static time_point Now() noexcept; | ||
| 21 | }; | ||
| 22 | |||
| 23 | } // namespace Common | ||