mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-01 14:59:13 +00:00
[common] remove presumed 'hot path' for QPC of 10MHz on SteadyClock::Now() (#4162)
while this may be true, it isn't required to have this quick path for this function because: a) arm64 b) counter/freq and counter%freq is a single idiv c) 2 muls, 2 div isnt that insanely expensive d) `static_assert(period::den % TenMHz == 0)` Signed-off-by: lizzie <[email protected]> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4162 Reviewed-by: MaranBr <[email protected]> Reviewed-by: CamilleLaVey <[email protected]>
This commit is contained in:
1 parent
9677522e6c
commit
94e9c2bd74
1 file changed
+4
-16
@@ -1,4 +1,4 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
@@ -48,22 +48,10 @@ static s64 GetSystemTimeNS() {
|
|||||||
|
|
||||||
SteadyClock::time_point SteadyClock::Now() noexcept {
|
SteadyClock::time_point SteadyClock::Now() noexcept {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
static const auto freq = WindowsQueryPerformanceFrequency();
|
static const auto timer_freq = WindowsQueryPerformanceFrequency();
|
||||||
const auto counter = WindowsQueryPerformanceCounter();
|
const auto counter = WindowsQueryPerformanceCounter();
|
||||||
|
const auto whole = (counter / timer_freq) * period::den;
|
||||||
// 10 MHz is a very common QPC frequency on modern PCs.
|
const auto part = (counter % timer_freq) * period::den / timer_freq;
|
||||||
// Optimizing for this specific frequency can double the performance of
|
|
||||||
// this function by avoiding the expensive frequency conversion path.
|
|
||||||
static constexpr s64 TenMHz = 10'000'000;
|
|
||||||
|
|
||||||
if (freq == TenMHz) [[likely]] {
|
|
||||||
static_assert(period::den % TenMHz == 0);
|
|
||||||
static constexpr s64 Multiplier = period::den / TenMHz;
|
|
||||||
return time_point{duration{counter * Multiplier}};
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto whole = (counter / freq) * period::den;
|
|
||||||
const auto part = (counter % freq) * period::den / freq;
|
|
||||||
return time_point{duration{whole + part}};
|
return time_point{duration{whole + part}};
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
return time_point{duration{clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW)}};
|
return time_point{duration{clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW)}};
|
||||||
|
|||||||
Reference in new issue
Block a user