Port yuzu-emu/yuzu#4472: "perf_stats: Mark GetMeanFrametime() as const" (#5498)

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.

Co-Authored-By: LC <lioncash@users.noreply.github.com>
This commit is contained in:
Tobias 2020-08-29 17:29:20 +02:00 committed by GitHub
parent a5fd11c213
commit 08e508e846
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View file

@ -73,15 +73,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);
return sum / (current_index - IgnoreFrames);
perf_history.begin() + current_index, 0.0);
return sum / static_cast<double>(current_index - IgnoreFrames);
}
PerfStats::Results PerfStats::GetAndResetStats(microseconds current_system_time_us) {
@ -110,7 +111,7 @@ PerfStats::Results PerfStats::GetAndResetStats(microseconds current_system_time_
return results;
}
double PerfStats::GetLastFrameTimeScale() {
double PerfStats::GetLastFrameTimeScale() const {
std::lock_guard lock{object_mutex};
constexpr double FRAME_LENGTH = 1.0 / GPU::SCREEN_REFRESH_RATE;