summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorSam Belliveau <sam.belliveau@gmail.com>2022-12-30 14:56:08 -0500
committerAdmiral H. Curtiss <pikachu025@gmail.com>2023-01-06 20:27:25 +0100
commit588a72a4fc7eb46f161687d0828afd9703e618ee (patch)
tree028fa07caf14086db76995921903b418cff640c9 /Source/Core
parentbc46089ab0ca7963ca3b5507969a3df0f2afca6c (diff)
PerformanceTracker: Add ownership of m_log_name.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/PerformanceMetrics.h2
-rw-r--r--Source/Core/VideoCommon/PerformanceTracker.cpp11
-rw-r--r--Source/Core/VideoCommon/PerformanceTracker.h6
3 files changed, 11 insertions, 8 deletions
diff --git a/Source/Core/VideoCommon/PerformanceMetrics.h b/Source/Core/VideoCommon/PerformanceMetrics.h
index b01c0782ab..eb6f8ecb00 100644
--- a/Source/Core/VideoCommon/PerformanceMetrics.h
+++ b/Source/Core/VideoCommon/PerformanceMetrics.h
@@ -34,7 +34,7 @@ public:
private:
PerformanceTracker m_fps_counter{"render_times.txt"};
PerformanceTracker m_vps_counter{"vblank_times.txt"};
- PerformanceTracker m_speed_counter{nullptr, 500000};
+ PerformanceTracker m_speed_counter{std::nullopt, 500000};
};
extern PerformanceMetrics g_perf_metrics;
diff --git a/Source/Core/VideoCommon/PerformanceTracker.cpp b/Source/Core/VideoCommon/PerformanceTracker.cpp
index 305fb35598..93b33cff9a 100644
--- a/Source/Core/VideoCommon/PerformanceTracker.cpp
+++ b/Source/Core/VideoCommon/PerformanceTracker.cpp
@@ -18,7 +18,7 @@
static constexpr double SAMPLE_RC_RATIO = 0.25;
-PerformanceTracker::PerformanceTracker(const char* log_name,
+PerformanceTracker::PerformanceTracker(const std::optional<std::string> log_name,
const std::optional<s64> sample_window_us)
: m_on_state_changed_handle{Core::AddOnStateChangedCallback([this](Core::State state) {
if (state == Core::State::Paused)
@@ -86,8 +86,7 @@ void PerformanceTracker::Count()
m_dt_std = std::nullopt;
- if (m_log_name && g_ActiveConfig.bLogRenderTimeToFile)
- LogRenderTimeToFile(diff);
+ LogRenderTimeToFile(diff);
}
DT PerformanceTracker::GetSampleWindow() const
@@ -230,9 +229,13 @@ bool PerformanceTracker::QueueEmpty() const
void PerformanceTracker::LogRenderTimeToFile(DT val)
{
+ if (!m_log_name || !g_ActiveConfig.bLogRenderTimeToFile)
+ return;
+
if (!m_bench_file.is_open())
{
- File::OpenFStream(m_bench_file, File::GetUserPath(D_LOGS_IDX) + m_log_name, std::ios_base::out);
+ File::OpenFStream(m_bench_file, File::GetUserPath(D_LOGS_IDX) + *m_log_name,
+ std::ios_base::out);
}
m_bench_file << std::fixed << std::setprecision(8) << DT_ms(val).count() << std::endl;
diff --git a/Source/Core/VideoCommon/PerformanceTracker.h b/Source/Core/VideoCommon/PerformanceTracker.h
index 4136664981..f24601c845 100644
--- a/Source/Core/VideoCommon/PerformanceTracker.h
+++ b/Source/Core/VideoCommon/PerformanceTracker.h
@@ -34,8 +34,8 @@ private:
}
public:
- PerformanceTracker(const char* log_name = nullptr,
- const std::optional<s64> sample_window_us = {});
+ PerformanceTracker(const std::optional<std::string> log_name = std::nullopt,
+ const std::optional<s64> sample_window_us = std::nullopt);
~PerformanceTracker();
PerformanceTracker(const PerformanceTracker&) = delete;
@@ -77,7 +77,7 @@ private: // Functions for managing dt queue
int m_on_state_changed_handle;
// Name of log file and file stream
- const char* m_log_name;
+ std::optional<std::string> m_log_name;
std::ofstream m_bench_file;
// Last time Count() was called