Special mode for callstack grouping in find zone menu.

This commit is contained in:
Bartosz Taudul 2019-02-27 20:37:38 +01:00
parent 851ae9077b
commit 422ed1f452
2 changed files with 206 additions and 112 deletions

View File

@ -5655,11 +5655,11 @@ void View::DrawFindZone()
ImGui::Separator();
auto& zoneData = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] );
if( ImGui::TreeNodeEx( "Histogram", ImGuiTreeNodeFlags_DefaultOpen ) )
{
const auto ty = ImGui::GetFontSize();
auto& zoneData = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] );
auto& zones = zoneData.zones;
const auto tmin = m_findZone.selfTime ? zoneData.selfMin : zoneData.min;
const auto tmax = m_findZone.selfTime ? zoneData.selfMax : zoneData.max;
@ -6406,6 +6406,97 @@ void View::DrawFindZone()
ImGui::BeginChild( "##zonesScroll", ImVec2( ImGui::GetWindowContentRegionWidth(), std::max( 200.f, ImGui::GetContentRegionAvail().y ) ) );
idx = 0;
if( groupBy == FindZone::GroupBy::Callstack )
{
const auto gsz = groups.size();
if( gsz > 0 )
{
if( m_findZone.selCs > gsz ) m_findZone.selCs = gsz;
const auto group = groups[m_findZone.selCs];
const bool selHilite = m_findZone.selGroup == group->first;
if( selHilite ) SetButtonHighlightColor();
#ifdef TRACY_EXTENDED_FONT
if( ImGui::SmallButton( " " ICON_FA_CHECK " " ) )
#else
if( ImGui::SmallButton( "Select" ) )
#endif
{
m_findZone.selGroup = group->first;
m_findZone.ResetSelection();
}
if( selHilite ) ImGui::PopStyleColor( 3 );
ImGui::SameLine();
#ifdef TRACY_EXTENDED_FONT
if( ImGui::SmallButton( " " ICON_FA_CARET_LEFT " " ) )
#else
if( ImGui::SmallButton( " < " ) )
#endif
{
m_findZone.selCs = std::max( m_findZone.selCs - 1, 0 );
}
ImGui::SameLine();
ImGui::Text( "%s / %s", RealToString( m_findZone.selCs + 1, true ), RealToString( gsz, true ) );
ImGui::SameLine();
#ifdef TRACY_EXTENDED_FONT
if( ImGui::SmallButton( " " ICON_FA_CARET_RIGHT " " ) )
#else
if( ImGui::SmallButton( " > " ) )
#endif
{
m_findZone.selCs = std::min<int>( m_findZone.selCs + 1, gsz - 1 );
}
ImGui::SameLine();
TextFocused( "Count:", RealToString( group->second.zones.size(), true ) );
ImGui::SameLine();
TextFocused( "Time:", TimeToString( group->second.time ) );
ImGui::SameLine();
ImGui::TextDisabled( "(%.2f%%)", group->second.time * 100.f / zoneData.total );
if( group->first != 0 )
{
ImGui::SameLine();
int fidx = 0;
#ifdef TRACY_EXTENDED_FONT
SmallCallstackButton( " " ICON_FA_ALIGN_JUSTIFY " ", group->first, fidx, false );
#else
SmallCallstackButton( "Call stack", group->first, fidx, false );
#endif
ImGui::Spacing();
ImGui::Indent();
auto& csdata = m_worker.GetCallstack( group->first );
for( auto& entry : csdata )
{
ImGui::TextDisabled( "%i.", fidx++ );
ImGui::SameLine();
auto frame = m_worker.GetCallstackFrame( entry );
if( !frame )
{
ImGui::Text( "0x%" PRIX64, entry );
}
else
{
ImGui::TextUnformatted( m_worker.GetString( frame->data[frame->size-1].name ) );
}
}
ImGui::Unindent();
}
else
{
ImGui::Text( "No call stack" );
}
ImGui::Spacing();
if( ImGui::TreeNodeEx( "Zone list" ) )
{
DrawZoneList( group->second.zones );
}
}
}
else
{
for( auto& v : groups )
{
const char* hdrString;
@ -6444,15 +6535,27 @@ void View::DrawFindZone()
ImGui::PopID();
ImGui::SameLine();
ImGui::TextColored( ImVec4( 0.5f, 0.5f, 0.5f, 1.0f ), "(%s) %s", RealToString( v->second.zones.size(), true ), TimeToString( v->second.time ) );
if( groupBy == FindZone::GroupBy::Callstack && v->first != 0 )
{
ImGui::SameLine();
SmallCallstackButton( "callstack", v->first, idx );
}
if( expand )
{
ImGui::Columns( 3, hdrString );
DrawZoneList( v->second.zones );
}
}
}
ImGui::EndChild();
if( ImGui::IsItemHovered() && ImGui::IsMouseClicked( 1 ) )
{
m_findZone.selGroup = m_findZone.Unselected;
m_findZone.ResetSelection();
}
}
#endif
ImGui::End();
}
void View::DrawZoneList( const Vector<ZoneEvent*>& zones )
{
ImGui::Columns( 3 );
ImGui::Separator();
if( ImGui::SmallButton( "Time from start" ) ) m_findZone.tableSortBy = FindZone::TableSortBy::Starttime;
ImGui::NextColumn();
@ -6464,14 +6567,14 @@ void View::DrawFindZone()
ImGui::NextColumn();
ImGui::Separator();
Vector<ZoneEvent*>* zonesToIterate = &v->second.zones;
const Vector<ZoneEvent*>* zonesToIterate = &zones;
Vector<ZoneEvent*> sortedZones;
if( m_findZone.tableSortBy != FindZone::TableSortBy::Starttime )
{
zonesToIterate = &sortedZones;
sortedZones.reserve_and_use( v->second.zones.size() );
memcpy( sortedZones.data(), v->second.zones.data(), v->second.zones.size() * sizeof( ZoneEvent* ) );
sortedZones.reserve_and_use( zones.size() );
memcpy( sortedZones.data(), zones.data(), zones.size() * sizeof( ZoneEvent* ) );
switch( m_findZone.tableSortBy )
{
@ -6537,18 +6640,6 @@ void View::DrawFindZone()
ImGui::Columns( 1 );
ImGui::Separator();
ImGui::TreePop();
}
}
ImGui::EndChild();
if( ImGui::IsItemHovered() && ImGui::IsMouseClicked( 1 ) )
{
m_findZone.selGroup = m_findZone.Unselected;
m_findZone.ResetSelection();
}
}
#endif
ImGui::End();
}
void View::DrawCompare()

View File

@ -131,6 +131,7 @@ private:
std::vector<CallstackFrameTree> GetCallstackFrameTreeBottomUp( const MemData& mem ) const;
std::vector<CallstackFrameTree> GetCallstackFrameTreeTopDown( const MemData& mem ) const;
void DrawFrameTreeLevel( std::vector<CallstackFrameTree>& tree, int& idx );
void DrawZoneList( const Vector<ZoneEvent*>& zones );
void DrawInfoWindow();
void DrawZoneInfoWindow();
@ -333,6 +334,7 @@ private:
bool drawAvgMed = true;
bool drawSelAvgMed = true;
bool scheduleResetMatch = false;
int selCs = 0;
void Reset()
{
@ -358,6 +360,7 @@ private:
ResetSelection();
groups.clear();
processed = 0;
selCs = 0;
}
void ResetSelection()