diff options
author | David <25727384+ogniK5377@users.noreply.github.com> | 2019-09-21 20:09:55 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-21 20:09:55 +1000 |
commit | 183c445c30ad9fa1f58660ff578ecf1b78e51b25 (patch) | |
tree | 045c4a6945449d563ea420fbf5a4916cbde1f8b3 /src/core/perf_stats.h | |
parent | c7c8ffbc137412226e4cbe40e567b7d7fb1a8799 (diff) | |
parent | d36a7a43c5f5d7d6dc6fb5945311c264ad79297c (diff) |
Merge pull request #2806 from FearlessTobi/port-4882
Port citra-emu/citra#4882: "Add frametime logging for tracking performance over time"
Diffstat (limited to 'src/core/perf_stats.h')
-rw-r--r-- | src/core/perf_stats.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h index 222ac1a63..d9a64f072 100644 --- a/src/core/perf_stats.h +++ b/src/core/perf_stats.h @@ -4,7 +4,9 @@ #pragma once +#include <array> #include <chrono> +#include <cstddef> #include <mutex> #include "common/common_types.h" @@ -27,6 +29,10 @@ struct PerfStatsResults { */ class PerfStats { public: + explicit PerfStats(u64 title_id); + + ~PerfStats(); + using Clock = std::chrono::high_resolution_clock; void BeginSystemFrame(); @@ -36,13 +42,26 @@ 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. */ 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<double, 216000> perf_history = {}; /// Point when the cumulative counters were reset Clock::time_point reset_point = Clock::now(); |