From 44b135f15756b83dff9e4a6f127f8408dc18f86d Mon Sep 17 00:00:00 2001 From: Light Date: Wed, 14 Jul 2021 00:16:10 +0430 Subject: [PATCH] Instrumentor - 'Instrumentor' now tracks the sessionn's submit count - 'Instrumentor::SubmitScopeProfileImpl' no longer uses a static variable --- Engine/src/Engine/Debug/Instrumentor.cpp | 15 ++++++++------- Engine/src/Engine/Debug/Instrumentor.h | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Engine/src/Engine/Debug/Instrumentor.cpp b/Engine/src/Engine/Debug/Instrumentor.cpp index ee755e4..acc579e 100644 --- a/Engine/src/Engine/Debug/Instrumentor.cpp +++ b/Engine/src/Engine/Debug/Instrumentor.cpp @@ -11,6 +11,7 @@ namespace Light { } Instrumentor::Instrumentor() + : m_CurrentSessionCount(0u) { // #todo: maintenance LT_ENGINE_ASSERT(!s_Context, "Instrumentor::Instrumentor: an instance of 'Instrumentor' already exists, do not construct this class!"); @@ -25,6 +26,11 @@ namespace Light { void Instrumentor::EndSessionImpl() { + if (m_CurrentSessionCount == 0u) + LT_ENGINE_WARN("Instrumentor::EndSessionImpl: 0 profiling for the ended session"); + + m_CurrentSessionCount = 0u; + m_OutputFileStream << "]}"; m_OutputFileStream.flush(); m_OutputFileStream.close(); @@ -32,14 +38,9 @@ namespace Light { void Instrumentor::SubmitScopeProfileImpl(const ScopeProfileResult& profileResult) { - static bool test = true; - - if (test) - { - test = false; + if (m_CurrentSessionCount++ == 0u) m_OutputFileStream << "{"; - } - else + else m_OutputFileStream << ",{"; m_OutputFileStream << "\"name\":\"" << profileResult.name << "\","; diff --git a/Engine/src/Engine/Debug/Instrumentor.h b/Engine/src/Engine/Debug/Instrumentor.h index a9152a9..04416e0 100644 --- a/Engine/src/Engine/Debug/Instrumentor.h +++ b/Engine/src/Engine/Debug/Instrumentor.h @@ -21,7 +21,8 @@ namespace Light { static Instrumentor* s_Context; std::ofstream m_OutputFileStream; - bool m_FirstScopeProfile = true; + + unsigned int m_CurrentSessionCount; public: static Instrumentor* Create();