summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFearlessTobi <thm.frey@gmail.com>2019-09-10 12:57:45 +0200
committerFearlessTobi <thm.frey@gmail.com>2019-09-10 12:57:45 +0200
commitd36a7a43c5f5d7d6dc6fb5945311c264ad79297c (patch)
treef764449755db789df6db727c39b6baa7bd89593e /src
parentAdd frametime logging for tracking performance over time (diff)
downloadyuzu-d36a7a43c5f5d7d6dc6fb5945311c264ad79297c.tar
yuzu-d36a7a43c5f5d7d6dc6fb5945311c264ad79297c.tar.gz
yuzu-d36a7a43c5f5d7d6dc6fb5945311c264ad79297c.tar.bz2
yuzu-d36a7a43c5f5d7d6dc6fb5945311c264ad79297c.tar.lz
yuzu-d36a7a43c5f5d7d6dc6fb5945311c264ad79297c.tar.xz
yuzu-d36a7a43c5f5d7d6dc6fb5945311c264ad79297c.tar.zst
yuzu-d36a7a43c5f5d7d6dc6fb5945311c264ad79297c.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/perf_stats.cpp14
-rw-r--r--src/core/perf_stats.h1
2 files changed, 9 insertions, 6 deletions
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp
index bfab77abb..d2c69d1a0 100644
--- a/src/core/perf_stats.cpp
+++ b/src/core/perf_stats.cpp
@@ -9,8 +9,8 @@
#include <numeric>
#include <sstream>
#include <thread>
+#include <fmt/chrono.h>
#include <fmt/format.h>
-#include <fmt/time.h>
#include "common/file_util.h"
#include "common/math_util.h"
#include "core/perf_stats.h"
@@ -34,13 +34,13 @@ PerfStats::~PerfStats() {
return;
}
- std::time_t t = std::time(nullptr);
+ const std::time_t t = std::time(nullptr);
std::ostringstream stream;
std::copy(perf_history.begin() + IgnoreFrames, perf_history.begin() + current_index,
std::ostream_iterator<double>(stream, "\n"));
- std::string path = FileUtil::GetUserPath(FileUtil::UserPath::LogDir);
+ const std::string& path = FileUtil::GetUserPath(FileUtil::UserPath::LogDir);
// %F Date format expanded is "%Y-%m-%d"
- std::string filename =
+ const std::string filename =
fmt::format("{}/{:%F-%H-%M}_{:016X}.csv", path, *std::localtime(&t), title_id);
FileUtil::IOFile file(filename, "w");
file.WriteString(stream.str());
@@ -75,11 +75,13 @@ void PerfStats::EndGameFrame() {
}
double PerfStats::GetMeanFrametime() {
+ std::lock_guard lock{object_mutex};
+
if (current_index <= IgnoreFrames) {
return 0;
}
- double sum = std::accumulate(perf_history.begin() + IgnoreFrames,
- perf_history.begin() + current_index, 0);
+ const double sum = std::accumulate(perf_history.begin() + IgnoreFrames,
+ perf_history.begin() + current_index, 0);
return sum / (current_index - IgnoreFrames);
}
diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h
index 2db290c09..d9a64f072 100644
--- a/src/core/perf_stats.h
+++ b/src/core/perf_stats.h
@@ -6,6 +6,7 @@
#include <array>
#include <chrono>
+#include <cstddef>
#include <mutex>
#include "common/common_types.h"