mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Add callstack sampling statistics.
This commit is contained in:
parent
852e37c8dd
commit
27466fc56b
@ -10946,6 +10946,16 @@ void View::DrawStatistics()
|
||||
return;
|
||||
}
|
||||
|
||||
bool instrumentationTab = true;
|
||||
const auto hasSampleData = m_worker.AreCallstackSamplesReady() && m_worker.GetCallstackSampleCount() > 0;
|
||||
if( hasSampleData )
|
||||
{
|
||||
ImGui::BeginTabBar( "StatisticsTabBar" );
|
||||
instrumentationTab = ImGui::BeginTabItem( "Instrumentation" );
|
||||
}
|
||||
|
||||
if( instrumentationTab )
|
||||
{
|
||||
#ifdef TRACY_EXTENDED_FONT
|
||||
m_statisticsFilter.Draw( ICON_FA_FILTER " Filter zones", 200 );
|
||||
#else
|
||||
@ -11110,6 +11120,146 @@ void View::DrawStatistics()
|
||||
}
|
||||
ImGui::EndColumns();
|
||||
ImGui::EndChild();
|
||||
|
||||
if( hasSampleData )
|
||||
{
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
|
||||
if( hasSampleData )
|
||||
{
|
||||
if( ImGui::BeginTabItem( "Sampling" ) )
|
||||
{
|
||||
|
||||
#ifdef TRACY_EXTENDED_FONT
|
||||
ImGui::Checkbox( ICON_FA_STOPWATCH " Show time", &m_statSampleTime );
|
||||
#else
|
||||
ImGui::Checkbox( "Show time", &m_statSampleTime );
|
||||
#endif
|
||||
ImGui::SameLine();
|
||||
#ifdef TRACY_EXTENDED_FONT
|
||||
ImGui::Checkbox( ICON_FA_CLOCK " Exclusive", &m_statSelf );
|
||||
#else
|
||||
ImGui::Checkbox( "Exclusive", &m_statSelf );
|
||||
#endif
|
||||
ImGui::Separator();
|
||||
ImGui::BeginChild( "##statisticsSampling" );
|
||||
|
||||
const auto& symMap = m_worker.GetSymbolMap();
|
||||
const auto& symStat = m_worker.GetSymbolStats();
|
||||
|
||||
const auto sssz = symStat.size();
|
||||
std::vector<decltype(symStat.begin())> data;
|
||||
data.reserve( sssz );
|
||||
auto statit = symStat.begin();
|
||||
while( statit != symStat.end() )
|
||||
{
|
||||
data.emplace_back( statit );
|
||||
++statit;
|
||||
}
|
||||
if( m_statSelf )
|
||||
{
|
||||
pdqsort_branchless( data.begin(), data.end(), []( const auto& l, const auto& r ) { return l->second.excl > r->second.excl; } );
|
||||
}
|
||||
else
|
||||
{
|
||||
pdqsort_branchless( data.begin(), data.end(), []( const auto& l, const auto& r ) { return l->second.incl > r->second.incl; } );
|
||||
}
|
||||
|
||||
const auto w = ImGui::GetWindowWidth();
|
||||
static bool widthSet = false;
|
||||
ImGui::Columns( 4 );
|
||||
if( !widthSet )
|
||||
{
|
||||
widthSet = true;
|
||||
ImGui::SetColumnWidth( 0, w * 0.3f );
|
||||
ImGui::SetColumnWidth( 1, w * 0.45f );
|
||||
ImGui::SetColumnWidth( 2, w * 0.15f );
|
||||
ImGui::SetColumnWidth( 3, w * 0.1f );
|
||||
}
|
||||
ImGui::TextUnformatted( "Name" );
|
||||
ImGui::NextColumn();
|
||||
ImGui::TextUnformatted( "Location" );
|
||||
ImGui::NextColumn();
|
||||
ImGui::TextUnformatted( "Module" );
|
||||
ImGui::NextColumn();
|
||||
ImGui::TextUnformatted( m_statSampleTime ? "Time" : "Count" );
|
||||
ImGui::NextColumn();
|
||||
ImGui::Separator();
|
||||
|
||||
const auto period = m_worker.GetSamplingPeriod();
|
||||
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;
|
||||
|
||||
auto sit = symMap.find( v->first );
|
||||
if( sit != symMap.end() )
|
||||
{
|
||||
name = m_worker.GetString( sit->second.name );
|
||||
file = m_worker.GetString( sit->second.file );
|
||||
imageName = m_worker.GetString( sit->second.imageName );
|
||||
line = sit->second.line;
|
||||
}
|
||||
|
||||
ImGui::TextUnformatted( name );
|
||||
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 );
|
||||
}
|
||||
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 ) );
|
||||
}
|
||||
ImGui::NextColumn();
|
||||
}
|
||||
}
|
||||
ImGui::EndColumns();
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
#endif
|
||||
ImGui::End();
|
||||
}
|
||||
|
@ -343,6 +343,7 @@ private:
|
||||
|
||||
int m_statSort = 0;
|
||||
bool m_statSelf = false;
|
||||
bool m_statSampleTime = true;
|
||||
int m_showCallstackFrameAddress = 0;
|
||||
bool m_showUnknownFrames = true;
|
||||
bool m_groupChildrenLocations = false;
|
||||
|
@ -425,6 +425,9 @@ public:
|
||||
const unordered_flat_map<int16_t, SourceLocationZones>& GetSourceLocationZones() const { return m_data.sourceLocationZones; }
|
||||
bool AreSourceLocationZonesReady() const { return m_data.sourceLocationZonesReady; }
|
||||
bool IsCpuUsageReady() const { return m_data.ctxUsageReady; }
|
||||
|
||||
const unordered_flat_map<uint64_t, SymbolData>& GetSymbolMap() const { return m_data.symbolMap; }
|
||||
const unordered_flat_map<uint64_t, SymbolStats>& GetSymbolStats() const { return m_data.symbolStats; }
|
||||
bool AreCallstackSamplesReady() const { return m_data.callstackSamplesReady; }
|
||||
#endif
|
||||
|
||||
@ -448,6 +451,7 @@ public:
|
||||
void Write( FileWrite& f );
|
||||
int GetTraceVersion() const { return m_traceVersion; }
|
||||
uint8_t GetHandshakeStatus() const { return m_handshake.load( std::memory_order_relaxed ); }
|
||||
int64_t GetSamplingPeriod() const { return m_samplingPeriod; }
|
||||
|
||||
static const LoadProgress& GetLoadProgress() { return s_loadProgress; }
|
||||
int64_t GetLoadTime() const { return m_loadTime; }
|
||||
|
Loading…
Reference in New Issue
Block a user