diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 2d772e90..bd4df31f 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -4230,21 +4230,6 @@ void View::DrawFindZone() ImGui::Separator(); ImGui::Text( "Found zones:" ); ImGui::SameLine(); - if( m_findZone.sortByCounts ) - { - if( ImGui::SmallButton( "Sort by order" ) ) - { - m_findZone.sortByCounts = false; - } - } - else - { - if( ImGui::SmallButton( "Sort by counts" ) ) - { - m_findZone.sortByCounts = true; - } - } - ImGui::SameLine(); ImGui::TextDisabled( "(?)" ); if( ImGui::IsItemHovered() ) { @@ -4259,6 +4244,8 @@ void View::DrawFindZone() m_findZone.ResetGroups(); } + ImGui::Combo( "Sort by", (int*)( &m_findZone.sortBy ), "Order\0Count\0Time\0\0" ); + auto& zones = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] ).zones; auto sz = zones.size(); auto processed = m_findZone.processed; @@ -4318,9 +4305,20 @@ void View::DrawFindZone() { groups[idx++] = it; } - if( m_findZone.sortByCounts ) + + switch( m_findZone.sortBy ) { + case FindZone::SortBy::Order: + break; + case FindZone::SortBy::Count: pdqsort_branchless( groups.begin(), groups.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.zones.size() > rhs->second.zones.size(); } ); + break; + case FindZone::SortBy::Time: + pdqsort_branchless( groups.begin(), groups.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.time > rhs->second.time; } ); + break; + default: + assert( false ); + break; } ImGui::BeginChild( "##zonesScroll", ImVec2( ImGui::GetWindowContentRegionWidth(), std::max( 200.f, ImGui::GetContentRegionAvail().y ) ) ); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 45c10434..6344b630 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -220,6 +220,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 }; struct Group { @@ -238,7 +239,7 @@ private: bool logTime = true; bool cumulateTime = false; GroupBy groupBy = GroupBy::Thread; - bool sortByCounts = false; + SortBy sortBy = SortBy::Order; Region highlight; int64_t numBins = -1; std::unique_ptr bins, binTime, selBin;