mirror of
https://github.com/wolfpld/tracy
synced 2025-04-30 12:53:51 +00:00
Use tables for time distribution.
This commit is contained in:
parent
34683ceb4d
commit
18ac6ee548
@ -7630,33 +7630,44 @@ void View::DrawZoneInfoWindow()
|
|||||||
std::vector<unordered_flat_map<int16_t, ZoneTimeData>::const_iterator> vec;
|
std::vector<unordered_flat_map<int16_t, ZoneTimeData>::const_iterator> vec;
|
||||||
vec.reserve( m_timeDist.data.size() );
|
vec.reserve( m_timeDist.data.size() );
|
||||||
for( auto it = m_timeDist.data.cbegin(); it != m_timeDist.data.cend(); ++it ) vec.emplace_back( it );
|
for( auto it = m_timeDist.data.cbegin(); it != m_timeDist.data.cend(); ++it ) vec.emplace_back( it );
|
||||||
static bool widthSet = false;
|
if( ImGui::BeginTable( "##timedist", 3, ImGuiTableFlags_Sortable | ImGuiTableFlags_BordersInnerV ) )
|
||||||
ImGui::Columns( 3 );
|
|
||||||
if( !widthSet )
|
|
||||||
{
|
{
|
||||||
widthSet = true;
|
ImGui::TableSetupColumn( "Zone", ImGuiTableColumnFlags_PreferSortDescending );
|
||||||
const auto w = ImGui::GetWindowWidth();
|
ImGui::TableSetupColumn( "Time", ImGuiTableColumnFlags_PreferSortDescending | ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthAutoResize );
|
||||||
ImGui::SetColumnWidth( 0, w * 0.57f );
|
ImGui::TableSetupColumn( "MTPC", ImGuiTableColumnFlags_PreferSortDescending | ImGuiTableColumnFlags_WidthAutoResize );
|
||||||
ImGui::SetColumnWidth( 1, w * 0.25f );
|
ImGui::TableHeadersRow();
|
||||||
ImGui::SetColumnWidth( 2, w * 0.18f );
|
const auto& sortspec = *ImGui::TableGetSortSpecs()->Specs;
|
||||||
|
switch( sortspec.ColumnIndex )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
if( sortspec.SortDirection == ImGuiSortDirection_Ascending )
|
||||||
|
{
|
||||||
|
pdqsort_branchless( vec.begin(), vec.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.count < rhs->second.count; } );
|
||||||
}
|
}
|
||||||
if( ImGui::SmallButton( "Zone" ) ) m_timeDist.sortBy = TimeDistribution::SortBy::Count;
|
else
|
||||||
ImGui::NextColumn();
|
|
||||||
if( ImGui::SmallButton( "Time" ) ) m_timeDist.sortBy = TimeDistribution::SortBy::Time;
|
|
||||||
ImGui::NextColumn();
|
|
||||||
if( ImGui::SmallButton( "MTPC" ) ) m_timeDist.sortBy = TimeDistribution::SortBy::Mtpc;
|
|
||||||
ImGui::NextColumn();
|
|
||||||
ImGui::Separator();
|
|
||||||
switch( m_timeDist.sortBy )
|
|
||||||
{
|
{
|
||||||
case TimeDistribution::SortBy::Count:
|
|
||||||
pdqsort_branchless( vec.begin(), vec.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.count > rhs->second.count; } );
|
pdqsort_branchless( vec.begin(), vec.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.count > rhs->second.count; } );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TimeDistribution::SortBy::Time:
|
case 1:
|
||||||
|
if( sortspec.SortDirection == ImGuiSortDirection_Ascending )
|
||||||
|
{
|
||||||
|
pdqsort_branchless( vec.begin(), vec.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.time < rhs->second.time; } );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pdqsort_branchless( vec.begin(), vec.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.time > rhs->second.time; } );
|
pdqsort_branchless( vec.begin(), vec.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.time > rhs->second.time; } );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TimeDistribution::SortBy::Mtpc:
|
case 2:
|
||||||
|
if( sortspec.SortDirection == ImGuiSortDirection_Ascending )
|
||||||
|
{
|
||||||
|
pdqsort_branchless( vec.begin(), vec.end(), []( const auto& lhs, const auto& rhs ) { return float( lhs->second.time ) / lhs->second.count < float( rhs->second.time ) / rhs->second.count; } );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pdqsort_branchless( vec.begin(), vec.end(), []( const auto& lhs, const auto& rhs ) { return float( lhs->second.time ) / lhs->second.count > float( rhs->second.time ) / rhs->second.count; } );
|
pdqsort_branchless( vec.begin(), vec.end(), []( const auto& lhs, const auto& rhs ) { return float( lhs->second.time ) / lhs->second.count > float( rhs->second.time ) / rhs->second.count; } );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert( false );
|
assert( false );
|
||||||
@ -7664,6 +7675,8 @@ void View::DrawZoneInfoWindow()
|
|||||||
}
|
}
|
||||||
for( auto& v : vec )
|
for( auto& v : vec )
|
||||||
{
|
{
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
const auto& sl = m_worker.GetSourceLocation( v->first );
|
const auto& sl = m_worker.GetSourceLocation( v->first );
|
||||||
SmallColorBox( GetSrcLocColor( sl, 0 ) );
|
SmallColorBox( GetSrcLocColor( sl, 0 ) );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -7674,17 +7687,17 @@ void View::DrawZoneInfoWindow()
|
|||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextDisabled( "(\xc3\x97%s)", RealToString( v->second.count ) );
|
ImGui::TextDisabled( "(\xc3\x97%s)", RealToString( v->second.count ) );
|
||||||
ImGui::NextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextUnformatted( TimeToString( v->second.time ) );
|
ImGui::TextUnformatted( TimeToString( v->second.time ) );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
char buf[64];
|
char buf[64];
|
||||||
PrintStringPercent( buf, v->second.time * m_timeDist.fztime );
|
PrintStringPercent( buf, v->second.time * m_timeDist.fztime );
|
||||||
TextDisabledUnformatted( buf );
|
TextDisabledUnformatted( buf );
|
||||||
ImGui::NextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextUnformatted( TimeToString( v->second.time / v->second.count ) );
|
ImGui::TextUnformatted( TimeToString( v->second.time / v->second.count ) );
|
||||||
ImGui::NextColumn();
|
|
||||||
}
|
}
|
||||||
ImGui::EndColumns();
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user