From b0d319890b2b0a5876209f084b1b84c5122cd66d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 30 Jan 2019 01:54:18 +0100 Subject: [PATCH] Allow sorting find zone groups by mean time per call. --- server/TracyView.cpp | 13 +++++++++++++ server/TracyView.hpp | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index a52a254e..2bba364c 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -5529,6 +5529,16 @@ void View::DrawFindZone() ImGui::RadioButton( "Count", (int*)( &m_findZone.sortBy ), (int)FindZone::SortBy::Count ); ImGui::SameLine(); ImGui::RadioButton( "Time", (int*)( &m_findZone.sortBy ), (int)FindZone::SortBy::Time ); + ImGui::SameLine(); + ImGui::RadioButton( "MTPC", (int*)( &m_findZone.sortBy ), (int)FindZone::SortBy::Mtpc ); + ImGui::SameLine(); + ImGui::TextDisabled( "(?)" ); + if( ImGui::IsItemHovered() ) + { + ImGui::BeginTooltip(); + ImGui::Text( "Mean time per call" ); + ImGui::EndTooltip(); + } auto& zones = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] ).zones; auto sz = zones.size(); @@ -5601,6 +5611,9 @@ void View::DrawFindZone() case FindZone::SortBy::Time: pdqsort_branchless( groups.begin(), groups.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.time > rhs->second.time; } ); break; + case FindZone::SortBy::Mtpc: + pdqsort_branchless( groups.begin(), groups.end(), []( const auto& lhs, const auto& rhs ) { return double( lhs->second.time ) / lhs->second.zones.size() > double( rhs->second.time ) / rhs->second.zones.size(); } ); + break; default: assert( false ); break; diff --git a/server/TracyView.hpp b/server/TracyView.hpp index d0a2c089..9b5290bf 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -290,7 +290,7 @@ private: struct FindZone { enum : uint64_t { Unselected = std::numeric_limits::max() - 1 }; enum class GroupBy : int { Thread, UserText, Callstack }; - enum class SortBy : int { Order, Count, Time }; + enum class SortBy : int { Order, Count, Time, Mtpc }; struct Group {