From 684b616f0d6445b753dded31554e0b006b6d2c3e Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Mon, 26 Aug 2019 17:29:08 +0200 Subject: Add frametime logging for tracking performance over time Co-Authored-By: jroweboy --- src/core/perf_stats.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/core/perf_stats.h') diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h index 222ac1a63..2db290c09 100644 --- a/src/core/perf_stats.h +++ b/src/core/perf_stats.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include "common/common_types.h" @@ -27,6 +28,10 @@ struct PerfStatsResults { */ class PerfStats { public: + explicit PerfStats(u64 title_id); + + ~PerfStats(); + using Clock = std::chrono::high_resolution_clock; void BeginSystemFrame(); @@ -35,6 +40,11 @@ public: PerfStatsResults GetAndResetStats(std::chrono::microseconds current_system_time_us); + /** + * Returns the Arthimetic Mean of all frametime values stored in the performance history. + */ + double GetMeanFrametime(); + /** * Gets the ratio between walltime and the emulated time of the previous system frame. This is * useful for scaling inputs or outputs moving between the two time domains. @@ -42,7 +52,15 @@ public: double GetLastFrameTimeScale(); private: - std::mutex object_mutex; + std::mutex object_mutex{}; + + /// Title ID for the game that is running. 0 if there is no game running yet + u64 title_id{0}; + /// Current index for writing to the perf_history array + std::size_t current_index{0}; + /// Stores an hour of historical frametime data useful for processing and tracking performance + /// regressions with code changes. + std::array perf_history = {}; /// Point when the cumulative counters were reset Clock::time_point reset_point = Clock::now(); -- cgit v1.2.3 From d36a7a43c5f5d7d6dc6fb5945311c264ad79297c Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Tue, 10 Sep 2019 12:57:45 +0200 Subject: Address review comments --- src/core/perf_stats.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/perf_stats.h') diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h index 2db290c09..d9a64f072 100644 --- a/src/core/perf_stats.h +++ b/src/core/perf_stats.h @@ -6,6 +6,7 @@ #include #include +#include #include #include "common/common_types.h" -- cgit v1.2.3