summaryrefslogtreecommitdiff
path: root/src/core/perf_stats.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2017-02-19 18:18:26 -0800
committerGravatar Yuri Kunde Schlesner2017-02-26 17:22:03 -0800
commit92c8bd4b1f650438274e50303a6d3f668924d071 (patch)
tree0c9e162129dabd2424ee329b51f5765a73f6a494 /src/core/perf_stats.cpp
parentAdd performance statistics to status bar (diff)
downloadyuzu-92c8bd4b1f650438274e50303a6d3f668924d071.tar.gz
yuzu-92c8bd4b1f650438274e50303a6d3f668924d071.tar.xz
yuzu-92c8bd4b1f650438274e50303a6d3f668924d071.zip
PerfStats: Add method to get the instantaneous time ratio
Diffstat (limited to 'src/core/perf_stats.cpp')
-rw-r--r--src/core/perf_stats.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp
index 6d9e603e4..8d9e521a3 100644
--- a/src/core/perf_stats.cpp
+++ b/src/core/perf_stats.cpp
@@ -6,6 +6,9 @@
6#include "core/hw/gpu.h" 6#include "core/hw/gpu.h"
7#include "core/perf_stats.h" 7#include "core/perf_stats.h"
8 8
9using DoubleSecs = std::chrono::duration<double, std::chrono::seconds::period>;
10using std::chrono::duration_cast;
11
9namespace Core { 12namespace Core {
10 13
11void PerfStats::BeginSystemFrame() { 14void PerfStats::BeginSystemFrame() {
@@ -16,6 +19,9 @@ void PerfStats::EndSystemFrame() {
16 auto frame_end = Clock::now(); 19 auto frame_end = Clock::now();
17 accumulated_frametime += frame_end - frame_begin; 20 accumulated_frametime += frame_end - frame_begin;
18 system_frames += 1; 21 system_frames += 1;
22
23 previous_frame_length = frame_end - previous_frame_end;
24 previous_frame_end = frame_end;
19} 25}
20 26
21void PerfStats::EndGameFrame() { 27void PerfStats::EndGameFrame() {
@@ -23,9 +29,6 @@ void PerfStats::EndGameFrame() {
23} 29}
24 30
25PerfStats::Results PerfStats::GetAndResetStats(u64 current_system_time_us) { 31PerfStats::Results PerfStats::GetAndResetStats(u64 current_system_time_us) {
26 using DoubleSecs = std::chrono::duration<double, std::chrono::seconds::period>;
27 using std::chrono::duration_cast;
28
29 auto now = Clock::now(); 32 auto now = Clock::now();
30 // Walltime elapsed since stats were reset 33 // Walltime elapsed since stats were reset
31 auto interval = duration_cast<DoubleSecs>(now - reset_point).count(); 34 auto interval = duration_cast<DoubleSecs>(now - reset_point).count();
@@ -50,4 +53,9 @@ PerfStats::Results PerfStats::GetAndResetStats(u64 current_system_time_us) {
50 return results; 53 return results;
51} 54}
52 55
56double PerfStats::GetLastFrameTimeScale() {
57 constexpr double FRAME_LENGTH = 1.0 / GPU::SCREEN_REFRESH_RATE;
58 return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH;
59}
60
53} // namespace Core 61} // namespace Core