Display "no entries" message in statistics menu, if appropriate.

This commit is contained in:
Bartosz Taudul 2020-03-26 22:15:58 +01:00
parent ef96ecd9b8
commit e6b0bfc90d

View File

@ -11523,87 +11523,95 @@ void View::DrawStatistics()
#endif #endif
ImGui::Separator(); ImGui::Separator();
ImGui::BeginChild( "##statistics" );
const auto w = ImGui::GetWindowWidth();
static bool widthSet = false;
ImGui::Columns( 5 );
if( !widthSet )
{
widthSet = true;
ImGui::SetColumnWidth( 0, w * 0.3f );
ImGui::SetColumnWidth( 1, w * 0.4f );
ImGui::SetColumnWidth( 2, w * 0.1f );
ImGui::SetColumnWidth( 3, w * 0.1f );
ImGui::SetColumnWidth( 4, w * 0.1f );
}
ImGui::TextUnformatted( "Name" );
ImGui::NextColumn();
ImGui::TextUnformatted( "Location" );
ImGui::NextColumn();
if( ImGui::SmallButton( "Total time" ) ) m_statSort = 0;
ImGui::NextColumn();
if( ImGui::SmallButton( "Counts" ) ) m_statSort = 1;
ImGui::NextColumn();
if( ImGui::SmallButton( "MTPC" ) ) m_statSort = 2;
ImGui::SameLine();
DrawHelpMarker( "Mean time per call" );
ImGui::NextColumn();
ImGui::Separator();
const auto lastTime = m_worker.GetLastTime(); if( srcloc.empty() )
for( auto& v : srcloc )
{ {
ImGui::PushID( v->first ); ImGui::TextUnformatted( "No entries to be displayed." );
auto& srcloc = m_worker.GetSourceLocation( v->first ); }
auto name = m_worker.GetString( srcloc.name.active ? srcloc.name : srcloc.function ); else
SmallColorBox( GetSrcLocColor( srcloc, 0 ) ); {
ImGui::SameLine(); ImGui::BeginChild( "##statistics" );
if( ImGui::Selectable( name, m_findZone.show && !m_findZone.match.empty() && m_findZone.match[m_findZone.selMatch] == v->first, ImGuiSelectableFlags_SpanAllColumns ) ) const auto w = ImGui::GetWindowWidth();
{ static bool widthSet = false;
m_findZone.ShowZone( v->first, name ); ImGui::Columns( 5 );
} if( !widthSet )
ImGui::NextColumn(); {
float indentVal = 0.f; widthSet = true;
if( m_statBuzzAnim.Match( v->first ) ) ImGui::SetColumnWidth( 0, w * 0.3f );
{ ImGui::SetColumnWidth( 1, w * 0.4f );
const auto time = m_statBuzzAnim.Time(); ImGui::SetColumnWidth( 2, w * 0.1f );
indentVal = sin( time * 60.f ) * 10.f * time; ImGui::SetColumnWidth( 3, w * 0.1f );
ImGui::Indent( indentVal ); ImGui::SetColumnWidth( 4, w * 0.1f );
} }
const auto file = m_worker.GetString( srcloc.file ); ImGui::TextUnformatted( "Name" );
ImGui::TextDisabled( "%s:%i", file, srcloc.line ); ImGui::NextColumn();
if( ImGui::IsItemClicked( 1 ) ) ImGui::TextUnformatted( "Location" );
{ ImGui::NextColumn();
if( SourceFileValid( file, m_worker.GetCaptureTime() ) ) if( ImGui::SmallButton( "Total time" ) ) m_statSort = 0;
{ ImGui::NextColumn();
SetTextEditorFile( file, srcloc.line, 0 ); if( ImGui::SmallButton( "Counts" ) ) m_statSort = 1;
} ImGui::NextColumn();
else if( ImGui::SmallButton( "MTPC" ) ) m_statSort = 2;
{ ImGui::SameLine();
m_statBuzzAnim.Enable( v->first, 0.5f ); DrawHelpMarker( "Mean time per call" );
} ImGui::NextColumn();
} ImGui::Separator();
if( indentVal != 0.f )
{ const auto lastTime = m_worker.GetLastTime();
ImGui::Unindent( indentVal ); for( auto& v : srcloc )
} {
ImGui::NextColumn(); ImGui::PushID( v->first );
const auto time = m_statSelf ? v->second.selfTotal : v->second.total; auto& srcloc = m_worker.GetSourceLocation( v->first );
ImGui::TextUnformatted( TimeToString( time ) ); auto name = m_worker.GetString( srcloc.name.active ? srcloc.name : srcloc.function );
ImGui::SameLine(); SmallColorBox( GetSrcLocColor( srcloc, 0 ) );
char buf[64]; ImGui::SameLine();
PrintStringPercent( buf, 100. * time / lastTime ); if( ImGui::Selectable( name, m_findZone.show && !m_findZone.match.empty() && m_findZone.match[m_findZone.selMatch] == v->first, ImGuiSelectableFlags_SpanAllColumns ) )
TextDisabledUnformatted( buf ); {
ImGui::NextColumn(); m_findZone.ShowZone( v->first, name );
ImGui::TextUnformatted( RealToString( v->second.zones.size() ) ); }
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::TextUnformatted( TimeToString( ( m_statSelf ? v->second.selfTotal : v->second.total ) / v->second.zones.size() ) ); float indentVal = 0.f;
ImGui::NextColumn(); if( m_statBuzzAnim.Match( v->first ) )
{
ImGui::PopID(); const auto time = m_statBuzzAnim.Time();
indentVal = sin( time * 60.f ) * 10.f * time;
ImGui::Indent( indentVal );
}
const auto file = m_worker.GetString( srcloc.file );
ImGui::TextDisabled( "%s:%i", file, srcloc.line );
if( ImGui::IsItemClicked( 1 ) )
{
if( SourceFileValid( file, m_worker.GetCaptureTime() ) )
{
SetTextEditorFile( file, srcloc.line, 0 );
}
else
{
m_statBuzzAnim.Enable( v->first, 0.5f );
}
}
if( indentVal != 0.f )
{
ImGui::Unindent( indentVal );
}
ImGui::NextColumn();
const auto time = m_statSelf ? v->second.selfTotal : v->second.total;
ImGui::TextUnformatted( TimeToString( time ) );
ImGui::SameLine();
char buf[64];
PrintStringPercent( buf, 100. * time / lastTime );
TextDisabledUnformatted( buf );
ImGui::NextColumn();
ImGui::TextUnformatted( RealToString( v->second.zones.size() ) );
ImGui::NextColumn();
ImGui::TextUnformatted( TimeToString( ( m_statSelf ? v->second.selfTotal : v->second.total ) / v->second.zones.size() ) );
ImGui::NextColumn();
ImGui::PopID();
}
ImGui::EndColumns();
ImGui::EndChild();
} }
ImGui::EndColumns();
ImGui::EndChild();
} }
else else
{ {
@ -11654,7 +11662,6 @@ void View::DrawStatistics()
ImGui::SameLine(); ImGui::SameLine();
ImGui::RadioButton( "Sample", &m_statSampleLocation, 1 ); ImGui::RadioButton( "Sample", &m_statSampleLocation, 1 );
ImGui::Separator(); ImGui::Separator();
ImGui::BeginChild( "##statisticsSampling" );
const auto& symMap = m_worker.GetSymbolMap(); const auto& symMap = m_worker.GetSymbolMap();
const auto& symStat = m_worker.GetSymbolStats(); const auto& symStat = m_worker.GetSymbolStats();
@ -11686,153 +11693,162 @@ void View::DrawStatistics()
++statit; ++statit;
} }
} }
if( m_statSelf )
if( data.empty() )
{ {
pdqsort_branchless( data.begin(), data.end(), []( const auto& l, const auto& r ) { return l->second.excl > r->second.excl; } ); ImGui::TextUnformatted( "No entries to be displayed." );
} }
else else
{ {
pdqsort_branchless( data.begin(), data.end(), []( const auto& l, const auto& r ) { return l->second.incl > r->second.incl; } ); if( m_statSelf )
}
const auto w = ImGui::GetWindowWidth();
static bool widthSet = false;
ImGui::Columns( 5 );
if( !widthSet )
{
widthSet = true;
ImGui::SetColumnWidth( 0, w * 0.3f );
ImGui::SetColumnWidth( 1, w * 0.375f );
ImGui::SetColumnWidth( 2, w * 0.125f );
ImGui::SetColumnWidth( 3, w * 0.125f );
ImGui::SetColumnWidth( 4, w * 0.075f );
}
ImGui::TextUnformatted( "Name" );
ImGui::NextColumn();
ImGui::TextUnformatted( "Location" );
ImGui::NextColumn();
ImGui::TextUnformatted( "Image" );
ImGui::NextColumn();
ImGui::TextUnformatted( m_statSampleTime ? "Time" : "Count" );
ImGui::NextColumn();
ImGui::TextUnformatted( "Code size" );
ImGui::NextColumn();
ImGui::Separator();
const auto period = m_worker.GetSamplingPeriod();
int idx = 0;
for( auto& v : data )
{
const auto cnt = m_statSelf ? v->second.excl : v->second.incl;
if( cnt > 0 )
{ {
const char* name = "[unknown]"; pdqsort_branchless( data.begin(), data.end(), []( const auto& l, const auto& r ) { return l->second.excl > r->second.excl; } );
const char* file = "[unknown]";
const char* imageName = "[unknown]";
uint32_t line = 0;
bool isInline = false;
uint32_t symlen = 0;
auto sit = symMap.find( v->first );
if( sit != symMap.end() )
{
name = m_worker.GetString( sit->second.name );
imageName = m_worker.GetString( sit->second.imageName );
isInline = sit->second.isInline;
if( m_statSampleLocation == 0 )
{
file = m_worker.GetString( sit->second.file );
line = sit->second.line;
}
else
{
file = m_worker.GetString( sit->second.callFile );
line = sit->second.callLine;
}
if( m_statHideUnknown && file[0] == '[' ) continue;
symlen = sit->second.size.Val();
}
else if( m_statHideUnknown )
{
continue;
}
if( isInline )
{
#ifdef TRACY_EXTENDED_FONT
TextDisabledUnformatted( ICON_FA_CARET_RIGHT );
#else
TextDisabledUnformatted( "inline" );
#endif
ImGui::SameLine();
}
if( v->first == 0 || v->second.excl == 0 )
{
ImGui::TextUnformatted( name );
}
else
{
ImGui::PushID( idx++ );
if( ImGui::Selectable( name, m_sampleParents.symAddr == v->first, ImGuiSelectableFlags_SpanAllColumns ) )
{
m_sampleParents.symAddr = v->first;
m_sampleParents.sel = 0;
}
ImGui::PopID();
}
ImGui::NextColumn();
float indentVal = 0.f;
if( m_statBuzzAnim.Match( v->first ) )
{
const auto time = m_statBuzzAnim.Time();
indentVal = sin( time * 60.f ) * 10.f * time;
ImGui::Indent( indentVal );
}
if( line > 0 )
{
ImGui::TextDisabled( "%s:%i", file, line );
}
else
{
TextDisabledUnformatted( file );
}
if( ImGui::IsItemClicked( 1 ) )
{
if( SourceFileValid( file, m_worker.GetCaptureTime() ) )
{
SetTextEditorFile( file, line, v->first );
}
else
{
m_statBuzzAnim.Enable( v->first, 0.5f );
}
}
if( indentVal != 0.f )
{
ImGui::Unindent( indentVal );
}
ImGui::NextColumn();
TextDisabledUnformatted( imageName );
ImGui::NextColumn();
if( m_statSampleTime )
{
ImGui::TextUnformatted( TimeToString( cnt * period ) );
}
else
{
ImGui::TextUnformatted( RealToString( cnt ) );
}
char buf[64];
PrintStringPercent( buf, 100. * cnt / m_worker.GetCallstackSampleCount() );
ImGui::SameLine();
TextDisabledUnformatted( buf );
ImGui::NextColumn();
if( symlen != 0 ) TextDisabledUnformatted( MemSizeToString( symlen ) );
ImGui::NextColumn();
} }
else
{
pdqsort_branchless( data.begin(), data.end(), []( const auto& l, const auto& r ) { return l->second.incl > r->second.incl; } );
}
ImGui::BeginChild( "##statisticsSampling" );
const auto w = ImGui::GetWindowWidth();
static bool widthSet = false;
ImGui::Columns( 5 );
if( !widthSet )
{
widthSet = true;
ImGui::SetColumnWidth( 0, w * 0.3f );
ImGui::SetColumnWidth( 1, w * 0.375f );
ImGui::SetColumnWidth( 2, w * 0.125f );
ImGui::SetColumnWidth( 3, w * 0.125f );
ImGui::SetColumnWidth( 4, w * 0.075f );
}
ImGui::TextUnformatted( "Name" );
ImGui::NextColumn();
ImGui::TextUnformatted( "Location" );
ImGui::NextColumn();
ImGui::TextUnformatted( "Image" );
ImGui::NextColumn();
ImGui::TextUnformatted( m_statSampleTime ? "Time" : "Count" );
ImGui::NextColumn();
ImGui::TextUnformatted( "Code size" );
ImGui::NextColumn();
ImGui::Separator();
const auto period = m_worker.GetSamplingPeriod();
int idx = 0;
for( auto& v : data )
{
const auto cnt = m_statSelf ? v->second.excl : v->second.incl;
if( cnt > 0 )
{
const char* name = "[unknown]";
const char* file = "[unknown]";
const char* imageName = "[unknown]";
uint32_t line = 0;
bool isInline = false;
uint32_t symlen = 0;
auto sit = symMap.find( v->first );
if( sit != symMap.end() )
{
name = m_worker.GetString( sit->second.name );
imageName = m_worker.GetString( sit->second.imageName );
isInline = sit->second.isInline;
if( m_statSampleLocation == 0 )
{
file = m_worker.GetString( sit->second.file );
line = sit->second.line;
}
else
{
file = m_worker.GetString( sit->second.callFile );
line = sit->second.callLine;
}
if( m_statHideUnknown && file[0] == '[' ) continue;
symlen = sit->second.size.Val();
}
else if( m_statHideUnknown )
{
continue;
}
if( isInline )
{
#ifdef TRACY_EXTENDED_FONT
TextDisabledUnformatted( ICON_FA_CARET_RIGHT );
#else
TextDisabledUnformatted( "inline" );
#endif
ImGui::SameLine();
}
if( v->first == 0 || v->second.excl == 0 )
{
ImGui::TextUnformatted( name );
}
else
{
ImGui::PushID( idx++ );
if( ImGui::Selectable( name, m_sampleParents.symAddr == v->first, ImGuiSelectableFlags_SpanAllColumns ) )
{
m_sampleParents.symAddr = v->first;
m_sampleParents.sel = 0;
}
ImGui::PopID();
}
ImGui::NextColumn();
float indentVal = 0.f;
if( m_statBuzzAnim.Match( v->first ) )
{
const auto time = m_statBuzzAnim.Time();
indentVal = sin( time * 60.f ) * 10.f * time;
ImGui::Indent( indentVal );
}
if( line > 0 )
{
ImGui::TextDisabled( "%s:%i", file, line );
}
else
{
TextDisabledUnformatted( file );
}
if( ImGui::IsItemClicked( 1 ) )
{
if( SourceFileValid( file, m_worker.GetCaptureTime() ) )
{
SetTextEditorFile( file, line, v->first );
}
else
{
m_statBuzzAnim.Enable( v->first, 0.5f );
}
}
if( indentVal != 0.f )
{
ImGui::Unindent( indentVal );
}
ImGui::NextColumn();
TextDisabledUnformatted( imageName );
ImGui::NextColumn();
if( m_statSampleTime )
{
ImGui::TextUnformatted( TimeToString( cnt * period ) );
}
else
{
ImGui::TextUnformatted( RealToString( cnt ) );
}
char buf[64];
PrintStringPercent( buf, 100. * cnt / m_worker.GetCallstackSampleCount() );
ImGui::SameLine();
TextDisabledUnformatted( buf );
ImGui::NextColumn();
if( symlen != 0 ) TextDisabledUnformatted( MemSizeToString( symlen ) );
ImGui::NextColumn();
}
}
ImGui::EndColumns();
ImGui::EndChild();
} }
ImGui::EndColumns();
ImGui::EndChild();
} }
#endif #endif
ImGui::End(); ImGui::End();