summaryrefslogtreecommitdiff
path: root/src/core/perf_stats.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2021-05-18 19:56:29 -0700
committerGravatar GitHub2021-05-18 19:56:29 -0700
commit7d86a6ff02e0778aa69ec52ef5c0eb0d26200818 (patch)
treeec9657e464e62c444ee2062cb0110b7e710d9788 /src/core/perf_stats.cpp
parentMerge pull request #6337 from Morph1984/transfer-mem-size (diff)
parentperf_stats: Rework FPS counter to be more accurate (diff)
downloadyuzu-7d86a6ff02e0778aa69ec52ef5c0eb0d26200818.tar.gz
yuzu-7d86a6ff02e0778aa69ec52ef5c0eb0d26200818.tar.xz
yuzu-7d86a6ff02e0778aa69ec52ef5c0eb0d26200818.zip
Merge pull request #6317 from ameerj/fps-fix
perf_stats: Rework FPS counter to be more accurate
Diffstat (limited to 'src/core/perf_stats.cpp')
-rw-r--r--src/core/perf_stats.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp
index b185a3884..c42c437b7 100644
--- a/src/core/perf_stats.cpp
+++ b/src/core/perf_stats.cpp
@@ -69,9 +69,7 @@ void PerfStats::EndSystemFrame() {
69} 69}
70 70
71void PerfStats::EndGameFrame() { 71void PerfStats::EndGameFrame() {
72 std::lock_guard lock{object_mutex}; 72 game_frames.fetch_add(1, std::memory_order_relaxed);
73
74 game_frames += 1;
75} 73}
76 74
77double PerfStats::GetMeanFrametime() const { 75double PerfStats::GetMeanFrametime() const {
@@ -94,10 +92,11 @@ PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us
94 const auto interval = duration_cast<DoubleSecs>(now - reset_point).count(); 92 const auto interval = duration_cast<DoubleSecs>(now - reset_point).count();
95 93
96 const auto system_us_per_second = (current_system_time_us - reset_point_system_us) / interval; 94 const auto system_us_per_second = (current_system_time_us - reset_point_system_us) / interval;
97 95 const auto current_frames = static_cast<double>(game_frames.load(std::memory_order_relaxed));
96 const auto current_fps = current_frames / interval;
98 const PerfStatsResults results{ 97 const PerfStatsResults results{
99 .system_fps = static_cast<double>(system_frames) / interval, 98 .system_fps = static_cast<double>(system_frames) / interval,
100 .game_fps = static_cast<double>(game_frames) / interval, 99 .average_game_fps = (current_fps + previous_fps) / 2.0,
101 .frametime = duration_cast<DoubleSecs>(accumulated_frametime).count() / 100 .frametime = duration_cast<DoubleSecs>(accumulated_frametime).count() /
102 static_cast<double>(system_frames), 101 static_cast<double>(system_frames),
103 .emulation_speed = system_us_per_second.count() / 1'000'000.0, 102 .emulation_speed = system_us_per_second.count() / 1'000'000.0,
@@ -108,7 +107,8 @@ PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us
108 reset_point_system_us = current_system_time_us; 107 reset_point_system_us = current_system_time_us;
109 accumulated_frametime = Clock::duration::zero(); 108 accumulated_frametime = Clock::duration::zero();
110 system_frames = 0; 109 system_frames = 0;
111 game_frames = 0; 110 game_frames.store(0, std::memory_order_relaxed);
111 previous_fps = current_fps;
112 112
113 return results; 113 return results;
114} 114}