From d49be792bab2fb2d65ab4d9d8377eac03a31be8a Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 6 Jun 2018 23:09:46 +0200 Subject: [PATCH] Cache bin containers in compare view. --- server/TracyView.cpp | 19 ++++++++++--------- server/TracyView.hpp | 8 ++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 295ef43c..ee8074ee 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -4059,12 +4059,6 @@ void View::DrawFindZone() ImGui::End(); } -struct CompVal -{ - double v0; - double v1; -}; - void View::DrawCompare() { ImGui::Begin( "Compare traces", &m_compare.show ); @@ -4258,10 +4252,17 @@ void View::DrawCompare() const auto numBins = int64_t( w - 4 ); if( numBins > 1 ) { - auto bins = std::make_unique( numBins ); - memset( bins.get(), 0, sizeof( CompVal ) * numBins ); + if( numBins != m_compare.numBins ) + { + m_compare.numBins = numBins; + m_compare.bins = std::make_unique( numBins ); + m_compare.binTime = std::make_unique( numBins ); + } - auto binTime = std::make_unique( numBins ); + const auto& bins = m_compare.bins; + const auto& binTime = m_compare.binTime; + + memset( bins.get(), 0, sizeof( CompVal ) * numBins ); memset( binTime.get(), 0, sizeof( CompVal ) * numBins ); if( m_compare.normalize ) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 8a19679b..a5ad55ff 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -238,6 +238,12 @@ private: } } m_findZone; + struct CompVal + { + double v0; + double v1; + }; + struct { bool show = false; std::unique_ptr second; @@ -249,6 +255,8 @@ private: bool logTime = true; bool cumulateTime = false; bool normalize = false; + int64_t numBins = -1; + std::unique_ptr bins, binTime; void Reset() {