From 0cffab04b5daf0e1f7557c523e7b7560fb06ae30 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Fri, 16 Aug 2019 21:33:16 -0600 Subject: [PATCH] Fixup! Prevent issue deleting PerfStats --- src/core/core.cpp | 10 ++++++---- src/core/core.h | 2 +- src/core/telemetry_session.cpp | 2 -- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index 56fd0798dc..162a4d2b1d 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -155,6 +155,10 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st status = ResultStatus::Success; m_emu_window = &emu_window; m_filepath = filepath; + + // Reset counters and set time origin to current frame + GetAndResetPerfStats(); + perf_stats->BeginSystemFrame(); return status; } @@ -235,10 +239,6 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window, u32 system_mo LOG_DEBUG(Core, "Initialized OK"); - // Reset counters and set time origin to current frame - GetAndResetPerfStats(); - perf_stats->BeginSystemFrame(); - return ResultStatus::Success; } @@ -315,6 +315,8 @@ void System::Shutdown() { perf_results.game_fps); telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Frametime", perf_results.frametime * 1000.0); + telemetry_session->AddField(Telemetry::FieldType::Performance, "Mean_Frametime_MS", + perf_stats->GetMeanFrametime()); // Shutdown emulation session GDBStub::Shutdown(); diff --git a/src/core/core.h b/src/core/core.h index ac5f2274e3..d4747ae362 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -216,7 +216,7 @@ public: /// Gets a const reference to the video dumper backend const VideoDumper::Backend& VideoDumper() const; - std::unique_ptr perf_stats = std::make_unique(0); + std::unique_ptr perf_stats; FrameLimiter frame_limiter; void SetStatus(ResultStatus new_status, const char* details = nullptr) { diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 417cf2f7ef..1049dd8c8b 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -99,8 +99,6 @@ TelemetrySession::~TelemetrySession() { std::chrono::system_clock::now().time_since_epoch()) .count()}; AddField(Telemetry::FieldType::Session, "Shutdown_Time", shutdown_time); - AddField(Telemetry::FieldType::Performance, "Mean_Frametime_MS", - Core::System::GetInstance().perf_stats->GetMeanFrametime()); #ifdef ENABLE_WEB_SERVICE auto backend = std::make_unique(Settings::values.web_api_url,