summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2020-08-03 14:12:03 +0200
committerLioncash <mathew1800@gmail.com>2020-08-03 18:33:35 +0200
commitd767be65bec5a834c4ed8fddc42df4720ec1a167 (patch)
treed55cba154034112fbdcd7fc921db767a3b48c753
parentMerge pull request #4437 from lioncash/ptr (diff)
downloadyuzu-d767be65bec5a834c4ed8fddc42df4720ec1a167.tar
yuzu-d767be65bec5a834c4ed8fddc42df4720ec1a167.tar.gz
yuzu-d767be65bec5a834c4ed8fddc42df4720ec1a167.tar.bz2
yuzu-d767be65bec5a834c4ed8fddc42df4720ec1a167.tar.lz
yuzu-d767be65bec5a834c4ed8fddc42df4720ec1a167.tar.xz
yuzu-d767be65bec5a834c4ed8fddc42df4720ec1a167.tar.zst
yuzu-d767be65bec5a834c4ed8fddc42df4720ec1a167.zip
-rw-r--r--src/core/perf_stats.cpp7
-rw-r--r--src/core/perf_stats.h11
2 files changed, 9 insertions, 9 deletions
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp
index 29339ead7..36372c66f 100644
--- a/src/core/perf_stats.cpp
+++ b/src/core/perf_stats.cpp
@@ -74,15 +74,16 @@ void PerfStats::EndGameFrame() {
game_frames += 1;
}
-double PerfStats::GetMeanFrametime() {
+double PerfStats::GetMeanFrametime() const {
std::lock_guard lock{object_mutex};
if (current_index <= IgnoreFrames) {
return 0;
}
+
const double sum = std::accumulate(perf_history.begin() + IgnoreFrames,
perf_history.begin() + current_index, 0.0);
- return sum / (current_index - IgnoreFrames);
+ return sum / static_cast<double>(current_index - IgnoreFrames);
}
PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us) {
@@ -111,7 +112,7 @@ PerfStatsResults PerfStats::GetAndResetStats(microseconds current_system_time_us
return results;
}
-double PerfStats::GetLastFrameTimeScale() {
+double PerfStats::GetLastFrameTimeScale() const {
std::lock_guard lock{object_mutex};
constexpr double FRAME_LENGTH = 1.0 / 60;
diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h
index d9a64f072..69256b960 100644
--- a/src/core/perf_stats.h
+++ b/src/core/perf_stats.h
@@ -30,7 +30,6 @@ struct PerfStatsResults {
class PerfStats {
public:
explicit PerfStats(u64 title_id);
-
~PerfStats();
using Clock = std::chrono::high_resolution_clock;
@@ -42,18 +41,18 @@ public:
PerfStatsResults GetAndResetStats(std::chrono::microseconds current_system_time_us);
/**
- * Returns the Arthimetic Mean of all frametime values stored in the performance history.
+ * Returns the arithmetic mean of all frametime values stored in the performance history.
*/
- double GetMeanFrametime();
+ double GetMeanFrametime() const;
/**
* 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();
+ double GetLastFrameTimeScale() const;
private:
- std::mutex object_mutex{};
+ mutable std::mutex object_mutex;
/// Title ID for the game that is running. 0 if there is no game running yet
u64 title_id{0};
@@ -61,7 +60,7 @@ private:
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 = {};
+ std::array<double, 216000> perf_history{};
/// Point when the cumulative counters were reset
Clock::time_point reset_point = Clock::now();