1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-09 16:23:54 +00:00

Add filter to sampling statistics.

This commit is contained in:
Bartosz Taudul 2020-02-27 02:31:30 +01:00
parent a66f4e0614
commit 8173f24515

View File

@ -11131,13 +11131,31 @@ void View::DrawStatistics()
{ {
if( ImGui::BeginTabItem( "Sampling" ) ) if( ImGui::BeginTabItem( "Sampling" ) )
{ {
#ifdef TRACY_EXTENDED_FONT
m_statisticsFilter.Draw( ICON_FA_FILTER " Filter zones", 200 );
#else
m_statisticsFilter.Draw( "Filter zones", 200 );
#endif
ImGui::SameLine();
#ifdef TRACY_EXTENDED_FONT
if( ImGui::Button( ICON_FA_BACKSPACE " Clear" ) )
#else
if( ImGui::Button( "Clear" ) )
#endif
{
m_statisticsFilter.Clear();
}
ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
#ifdef TRACY_EXTENDED_FONT #ifdef TRACY_EXTENDED_FONT
ImGui::Checkbox( ICON_FA_STOPWATCH " Show time", &m_statSampleTime ); ImGui::Checkbox( ICON_FA_STOPWATCH " Show time", &m_statSampleTime );
#else #else
ImGui::Checkbox( "Show time", &m_statSampleTime ); ImGui::Checkbox( "Show time", &m_statSampleTime );
#endif #endif
ImGui::SameLine(); ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
#ifdef TRACY_EXTENDED_FONT #ifdef TRACY_EXTENDED_FONT
ImGui::Checkbox( ICON_FA_CLOCK " Exclusive", &m_statSelf ); ImGui::Checkbox( ICON_FA_CLOCK " Exclusive", &m_statSelf );
#else #else
@ -11149,15 +11167,33 @@ void View::DrawStatistics()
const auto& symMap = m_worker.GetSymbolMap(); const auto& symMap = m_worker.GetSymbolMap();
const auto& symStat = m_worker.GetSymbolStats(); const auto& symStat = m_worker.GetSymbolStats();
const auto sssz = symStat.size(); Vector<decltype(symStat.begin())> data;
std::vector<decltype(symStat.begin())> data; data.reserve( symStat.size() );
data.reserve( sssz );
auto statit = symStat.begin(); auto statit = symStat.begin();
if( m_statisticsFilter.IsActive() )
{
while( statit != symStat.end() ) while( statit != symStat.end() )
{ {
data.emplace_back( statit ); auto sit = symMap.find( statit->first );
if( sit != symMap.end() )
{
auto name = m_worker.GetString( sit->second.name );
if( m_statisticsFilter.PassFilter( name ) )
{
data.push_back_no_space_check( statit );
}
}
++statit; ++statit;
} }
}
else
{
while( statit != symStat.end() )
{
data.push_back_no_space_check( statit );
++statit;
}
}
if( m_statSelf ) if( m_statSelf )
{ {
pdqsort_branchless( data.begin(), data.end(), []( const auto& l, const auto& r ) { return l->second.excl > r->second.excl; } ); pdqsort_branchless( data.begin(), data.end(), []( const auto& l, const auto& r ) { return l->second.excl > r->second.excl; } );