aboutsummaryrefslogtreecommitdiff
path: root/src/core/perf_stats.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2020-08-03 08:12:03 -0400
committerLioncash <mathew1800@gmail.com>2020-08-03 12:33:35 -0400
commitd767be65bec5a834c4ed8fddc42df4720ec1a167 (patch)
treed55cba154034112fbdcd7fc921db767a3b48c753 /src/core/perf_stats.cpp
parent05781ce8c4dd4d4150185effac56ef9a71ae2705 (diff)
perf_stats: Mark GetMeanFrametime() as const
The general pattern is to mark mutexes as mutable when it comes to matters of constness, given the mutex acts as a transient member of a data structure.
Diffstat (limited to 'src/core/perf_stats.cpp')
-rw-r--r--src/core/perf_stats.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp
index 29339ead7e..36372c66f0 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;