diff options
| author | 2019-08-26 17:29:08 +0200 | |
|---|---|---|
| committer | 2019-09-10 12:44:19 +0200 | |
| commit | 684b616f0d6445b753dded31554e0b006b6d2c3e (patch) | |
| tree | 6caaae05a26149df5919a3876c1b0b4b4789614d /src/core/perf_stats.h | |
| parent | Merge pull request #2847 from VelocityRa/nro-nacp-fix (diff) | |
| download | yuzu-684b616f0d6445b753dded31554e0b006b6d2c3e.tar.gz yuzu-684b616f0d6445b753dded31554e0b006b6d2c3e.tar.xz yuzu-684b616f0d6445b753dded31554e0b006b6d2c3e.zip | |
Add frametime logging for tracking performance over time
Co-Authored-By: jroweboy <jroweboy@gmail.com>
Diffstat (limited to 'src/core/perf_stats.h')
| -rw-r--r-- | src/core/perf_stats.h | 20 |
1 files changed, 19 insertions, 1 deletions
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 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 7 | #include <chrono> | 8 | #include <chrono> |
| 8 | #include <mutex> | 9 | #include <mutex> |
| 9 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| @@ -27,6 +28,10 @@ struct PerfStatsResults { | |||
| 27 | */ | 28 | */ |
| 28 | class PerfStats { | 29 | class PerfStats { |
| 29 | public: | 30 | public: |
| 31 | explicit PerfStats(u64 title_id); | ||
| 32 | |||
| 33 | ~PerfStats(); | ||
| 34 | |||
| 30 | using Clock = std::chrono::high_resolution_clock; | 35 | using Clock = std::chrono::high_resolution_clock; |
| 31 | 36 | ||
| 32 | void BeginSystemFrame(); | 37 | void BeginSystemFrame(); |
| @@ -36,13 +41,26 @@ public: | |||
| 36 | PerfStatsResults GetAndResetStats(std::chrono::microseconds current_system_time_us); | 41 | PerfStatsResults GetAndResetStats(std::chrono::microseconds current_system_time_us); |
| 37 | 42 | ||
| 38 | /** | 43 | /** |
| 44 | * Returns the Arthimetic Mean of all frametime values stored in the performance history. | ||
| 45 | */ | ||
| 46 | double GetMeanFrametime(); | ||
| 47 | |||
| 48 | /** | ||
| 39 | * Gets the ratio between walltime and the emulated time of the previous system frame. This is | 49 | * Gets the ratio between walltime and the emulated time of the previous system frame. This is |
| 40 | * useful for scaling inputs or outputs moving between the two time domains. | 50 | * useful for scaling inputs or outputs moving between the two time domains. |
| 41 | */ | 51 | */ |
| 42 | double GetLastFrameTimeScale(); | 52 | double GetLastFrameTimeScale(); |
| 43 | 53 | ||
| 44 | private: | 54 | private: |
| 45 | std::mutex object_mutex; | 55 | std::mutex object_mutex{}; |
| 56 | |||
| 57 | /// Title ID for the game that is running. 0 if there is no game running yet | ||
| 58 | u64 title_id{0}; | ||
| 59 | /// Current index for writing to the perf_history array | ||
| 60 | std::size_t current_index{0}; | ||
| 61 | /// Stores an hour of historical frametime data useful for processing and tracking performance | ||
| 62 | /// regressions with code changes. | ||
| 63 | std::array<double, 216000> perf_history = {}; | ||
| 46 | 64 | ||
| 47 | /// Point when the cumulative counters were reset | 65 | /// Point when the cumulative counters were reset |
| 48 | Clock::time_point reset_point = Clock::now(); | 66 | Clock::time_point reset_point = Clock::now(); |