From fc40c7bbf6c493c98ee7971d1fb44fcaaa79baab Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 3 Sep 2018 20:34:07 +0200 Subject: [PATCH] Calculate compare traces average, median. --- server/TracyView.cpp | 39 ++++++++++++++++++++++++++++++++++++--- server/TracyView.hpp | 18 ++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 0214b63d..73f62966 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -5552,7 +5552,7 @@ void View::DrawCompare() ImGui::Separator(); ImGui::NextColumn(); - auto prev = m_compare.selMatch[0]; + const auto prev0 = m_compare.selMatch[0]; int idx = 0; for( auto& v : m_compare.match[0] ) { @@ -5566,7 +5566,7 @@ void View::DrawCompare() } ImGui::NextColumn(); - prev = m_compare.selMatch[1]; + const auto prev1 = m_compare.selMatch[1]; idx = 0; for( auto& v : m_compare.match[1] ) { @@ -5579,9 +5579,13 @@ void View::DrawCompare() ImGui::PopID(); } ImGui::NextColumn(); - ImGui::EndColumns(); ImGui::TreePop(); + + if( prev0 != m_compare.selMatch[0] || prev1 != m_compare.selMatch[1] ) + { + m_compare.ResetSelection(); + } } ImGui::Separator(); @@ -5605,6 +5609,35 @@ void View::DrawCompare() auto tmin = std::min( zoneData0.min, zoneData1.min ); auto tmax = std::max( zoneData0.max, zoneData1.max );; + const size_t zsz[2] = { zones0.size(), zones1.size() }; + for( int k=0; k<2; k++ ) + { + if( m_compare.sortedNum[k] != zsz[k] ) + { + auto& zones = k == 0 ? zones0 : zones1; + auto& vec = m_compare.sorted[k]; + vec.reserve( zsz[k] ); + int64_t total = m_compare.total[k]; + size_t i; + for( i=m_compare.sortedNum[k]; i::max() ) { ImGui::Checkbox( "Log values", &m_compare.logVal ); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 3fe2b9ea..17f27ee7 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -367,9 +367,27 @@ private: bool normalize = false; int64_t numBins = -1; std::unique_ptr bins, binTime; + std::vector sorted[2]; + size_t sortedNum[2] = { 0, 0 }; + float average[2]; + float median[2]; + int64_t total[2]; + + void ResetSelection() + { + for( int i=0; i<2; i++ ) + { + sorted[i].clear(); + sortedNum[i] = 0; + average[i] = 0; + median[i] = 0; + total[i] = 0; + } + } void Reset() { + ResetSelection(); for( int i=0; i<2; i++ ) { match[i].clear();