diff options
| author | JosJuice <josjuice@gmail.com> | 2025-03-17 23:20:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-17 23:20:41 +0100 |
| commit | 029954020938855b05f7ed199ef482ea24de5530 (patch) | |
| tree | 2629a79878e3ac457c155795e65548939962f8ad /Source/Core/VideoCommon/PerformanceMetrics.cpp | |
| parent | 3b8384acf671e56401fc097d99315f716d876dc1 (diff) | |
| parent | 2690a62949617c6cf7964e7972b8f95eb1588216 (diff) | |
Merge pull request #13397 from jordan-woyak/perf-metrics
PerformanceMetrics: Eliminated a mutex. Code cleanups.
Diffstat (limited to 'Source/Core/VideoCommon/PerformanceMetrics.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PerformanceMetrics.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/Source/Core/VideoCommon/PerformanceMetrics.cpp b/Source/Core/VideoCommon/PerformanceMetrics.cpp index 773dc44383..163ac821a4 100644 --- a/Source/Core/VideoCommon/PerformanceMetrics.cpp +++ b/Source/Core/VideoCommon/PerformanceMetrics.cpp @@ -4,13 +4,13 @@ #include "VideoCommon/PerformanceMetrics.h" #include <algorithm> -#include <mutex> #include <imgui.h> #include <implot.h> #include "Core/Config/GraphicsSettings.h" #include "Core/CoreTiming.h" +#include "Core/HW/SystemTimers.h" #include "Core/HW/VideoInterface.h" #include "Core/System.h" #include "VideoCommon/VideoConfig.h" @@ -25,7 +25,8 @@ void PerformanceMetrics::Reset() m_time_sleeping = DT::zero(); m_real_times.fill(Clock::now()); - m_cpu_times.fill(Core::System::GetInstance().GetCoreTiming().GetCPUTimePoint(0)); + m_core_ticks.fill(0); + m_max_speed = 0; } void PerformanceMetrics::CountFrame() @@ -40,18 +41,25 @@ void PerformanceMetrics::CountVBlank() void PerformanceMetrics::CountThrottleSleep(DT sleep) { - std::unique_lock lock(m_time_lock); m_time_sleeping += sleep; } -void PerformanceMetrics::CountPerformanceMarker(Core::System& system, s64 cyclesLate) +void PerformanceMetrics::CountPerformanceMarker(Core::System& system, s64 cycles_late) { - std::unique_lock lock(m_time_lock); m_speed_counter.Count(); - m_real_times[m_time_index] = Clock::now() - m_time_sleeping; - m_cpu_times[m_time_index] = system.GetCoreTiming().GetCPUTimePoint(cyclesLate); - m_time_index += 1; + const auto ticks = system.GetCoreTiming().GetTicks() - cycles_late; + const auto real_time = Clock::now() - m_time_sleeping; + + auto& oldest_ticks = m_core_ticks[m_time_index]; + auto& oldest_time = m_real_times[m_time_index]; + + m_max_speed = DT_s(ticks - oldest_ticks) / system.GetSystemTimers().GetTicksPerSecond() / + (real_time - oldest_time); + + oldest_ticks = ticks; + oldest_time = real_time; + ++m_time_index; } double PerformanceMetrics::GetFPS() const @@ -71,15 +79,7 @@ double PerformanceMetrics::GetSpeed() const double PerformanceMetrics::GetMaxSpeed() const { - std::shared_lock lock(m_time_lock); - return DT_s(m_cpu_times[u8(m_time_index - 1)] - m_cpu_times[m_time_index]) / - DT_s(m_real_times[u8(m_time_index - 1)] - m_real_times[m_time_index]); -} - -double PerformanceMetrics::GetLastSpeedDenominator() const -{ - return DT_s(m_speed_counter.GetLastRawDt()).count() * - Core::System::GetInstance().GetVideoInterface().GetTargetRefreshRate(); + return m_max_speed; } void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) |
