Allow sorting zone groups by count.

This commit is contained in:
Bartosz Taudul 2018-03-20 17:19:48 +01:00
parent 64f3c55ba5
commit 4837ce31ff
2 changed files with 36 additions and 9 deletions

View File

@ -3295,6 +3295,21 @@ void View::DrawFindZone()
m_findZone.ResetThreads(); m_findZone.ResetThreads();
} }
} }
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;
}
}
auto& zones = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] ).zones; auto& zones = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] ).zones;
auto sz = zones.size(); auto sz = zones.size();
@ -3338,28 +3353,39 @@ void View::DrawFindZone()
} }
m_findZone.processed = processed; m_findZone.processed = processed;
ImGui::BeginChild( "##zonesScroll", ImVec2( ImGui::GetWindowContentRegionWidth(), std::max( 200.f, ImGui::GetContentRegionAvail().y ) ) ); Vector<decltype( m_findZone.threads )::iterator> threads;
threads.reserve_and_use( m_findZone.threads.size() );
int idx = 0; int idx = 0;
for( auto& v : m_findZone.threads ) for( auto it = m_findZone.threads.begin(); it != m_findZone.threads.end(); ++it )
{
threads[idx++] = it;
}
if( m_findZone.sortByCounts )
{
std::sort( threads.begin(), threads.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.size() > rhs->second.size(); } );
}
ImGui::BeginChild( "##zonesScroll", ImVec2( ImGui::GetWindowContentRegionWidth(), std::max( 200.f, ImGui::GetContentRegionAvail().y ) ) );
for( auto& v : threads )
{ {
const char* hdrString; const char* hdrString;
if( showThreads ) if( showThreads )
{ {
hdrString = m_worker.GetThreadString( m_worker.DecompressThread( v.first ) ); hdrString = m_worker.GetThreadString( m_worker.DecompressThread( v->first ) );
} }
else else
{ {
hdrString = v.first == std::numeric_limits<uint64_t>::max() ? "No user text" : m_worker.GetString( StringIdx( v.first ) ); hdrString = v->first == std::numeric_limits<uint64_t>::max() ? "No user text" : m_worker.GetString( StringIdx( v->first ) );
} }
ImGui::PushID( idx++ ); ImGui::PushID( v->first );
const bool expand = ImGui::TreeNodeEx( hdrString, ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ( v.first == m_findZone.selThread ? ImGuiTreeNodeFlags_Selected : 0 ) ); const bool expand = ImGui::TreeNodeEx( hdrString, ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ( v->first == m_findZone.selThread ? ImGuiTreeNodeFlags_Selected : 0 ) );
if( ImGui::IsItemClicked() ) if( ImGui::IsItemClicked() )
{ {
m_findZone.selThread = v.first; m_findZone.selThread = v->first;
} }
ImGui::PopID(); ImGui::PopID();
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextColored( ImVec4( 0.5f, 0.5f, 0.5f, 1.0f ), "(%s)", RealToString( v.second.size(), true ) ); ImGui::TextColored( ImVec4( 0.5f, 0.5f, 0.5f, 1.0f ), "(%s)", RealToString( v->second.size(), true ) );
if( expand ) if( expand )
{ {
@ -3374,7 +3400,7 @@ void View::DrawFindZone()
ImGui::Separator(); ImGui::Separator();
uint32_t cnt = 0; uint32_t cnt = 0;
for( auto& ev : v.second ) for( auto& ev : v->second )
{ {
const auto end = m_worker.GetZoneEndDirect( *ev ); const auto end = m_worker.GetZoneEndDirect( *ev );
const auto timespan = end - ev->start; const auto timespan = end - ev->start;

View File

@ -181,6 +181,7 @@ private:
bool logTime = false; bool logTime = false;
bool cumulateTime = false; bool cumulateTime = false;
bool showThreads = true; bool showThreads = true;
bool sortByCounts = false;
Region highlight; Region highlight;
void Reset() void Reset()