From 588a72a4fc7eb46f161687d0828afd9703e618ee Mon Sep 17 00:00:00 2001 From: Sam Belliveau Date: Fri, 30 Dec 2022 14:56:08 -0500 Subject: PerformanceTracker: Add ownership of m_log_name. --- Source/Core/VideoCommon/PerformanceTracker.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Source/Core/VideoCommon/PerformanceTracker.cpp') 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 log_name, const std::optional 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; -- cgit v1.2.3