mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
More find zones extraction.
This commit is contained in:
parent
a6cee9e7f7
commit
1aeb1d9a2d
@ -6800,181 +6800,6 @@ void View::DrawHistogramMinMaxLabel( ImDrawList* draw, int64_t tmin, int64_t tma
|
||||
draw->AddText( wpos + ImVec2( round( (w-1-rsz) * 0.5 ), ty15 ), 0x66FFFFFF, range );
|
||||
}
|
||||
|
||||
void View::DrawZoneList( int id, const Vector<short_ptr<ZoneEvent>>& zones )
|
||||
{
|
||||
const auto zsz = zones.size();
|
||||
char buf[32];
|
||||
sprintf( buf, "%i##zonelist", id );
|
||||
if( !ImGui::BeginTable( buf, 3, ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Resizable | ImGuiTableFlags_Hideable | ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_Sortable | ImGuiTableFlags_ScrollY, ImVec2( 0, ImGui::GetTextLineHeightWithSpacing() * std::min<size_t>( zsz + 1, 15 ) ) ) ) return;
|
||||
ImGui::TableSetupScrollFreeze( 0, 1 );
|
||||
ImGui::TableSetupColumn( "Time from start" );
|
||||
ImGui::TableSetupColumn( "Execution time", ImGuiTableColumnFlags_PreferSortDescending );
|
||||
ImGui::TableSetupColumn( "Name", ImGuiTableColumnFlags_NoSort );
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
const Vector<short_ptr<ZoneEvent>>* zonesToIterate = &zones;
|
||||
Vector<short_ptr<ZoneEvent>> sortedZones;
|
||||
|
||||
const auto& sortspec = *ImGui::TableGetSortSpecs()->Specs;
|
||||
if( sortspec.ColumnIndex != 0 || sortspec.SortDirection != ImGuiSortDirection_Ascending )
|
||||
{
|
||||
zonesToIterate = &sortedZones;
|
||||
sortedZones.reserve_and_use( zones.size() );
|
||||
memcpy( sortedZones.data(), zones.data(), zones.size() * sizeof( decltype( *zones.begin() ) ) );
|
||||
|
||||
switch( sortspec.ColumnIndex )
|
||||
{
|
||||
case 0:
|
||||
assert( sortspec.SortDirection != ImGuiSortDirection_Descending );
|
||||
std::reverse( sortedZones.begin(), sortedZones.end() );
|
||||
break;
|
||||
case 1:
|
||||
if( m_findZone.selfTime )
|
||||
{
|
||||
if( sortspec.SortDirection == ImGuiSortDirection_Descending )
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
return m_worker.GetZoneEndDirect( *lhs ) - lhs->Start() - this->GetZoneChildTimeFast( *lhs ) >
|
||||
m_worker.GetZoneEndDirect( *rhs ) - rhs->Start() - this->GetZoneChildTimeFast( *rhs );
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
return m_worker.GetZoneEndDirect( *lhs ) - lhs->Start() - this->GetZoneChildTimeFast( *lhs ) <
|
||||
m_worker.GetZoneEndDirect( *rhs ) - rhs->Start() - this->GetZoneChildTimeFast( *rhs );
|
||||
} );
|
||||
}
|
||||
}
|
||||
else if( m_findZone.runningTime )
|
||||
{
|
||||
if( sortspec.SortDirection == ImGuiSortDirection_Descending )
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
const auto ctx0 = m_worker.GetContextSwitchData( GetZoneThread( *lhs ) );
|
||||
const auto ctx1 = m_worker.GetContextSwitchData( GetZoneThread( *rhs ) );
|
||||
int64_t t0, t1;
|
||||
uint64_t c0, c1;
|
||||
GetZoneRunningTime( ctx0, *lhs, t0, c0 );
|
||||
GetZoneRunningTime( ctx1, *rhs, t1, c1 );
|
||||
return t0 > t1;
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
const auto ctx0 = m_worker.GetContextSwitchData( GetZoneThread( *lhs ) );
|
||||
const auto ctx1 = m_worker.GetContextSwitchData( GetZoneThread( *rhs ) );
|
||||
int64_t t0, t1;
|
||||
uint64_t c0, c1;
|
||||
GetZoneRunningTime( ctx0, *lhs, t0, c0 );
|
||||
GetZoneRunningTime( ctx1, *rhs, t1, c1 );
|
||||
return t0 < t1;
|
||||
} );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( sortspec.SortDirection == ImGuiSortDirection_Descending )
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
return m_worker.GetZoneEndDirect( *lhs ) - lhs->Start() > m_worker.GetZoneEndDirect( *rhs ) - rhs->Start();
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
return m_worker.GetZoneEndDirect( *lhs ) - lhs->Start() < m_worker.GetZoneEndDirect( *rhs ) - rhs->Start();
|
||||
} );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if( sortspec.SortDirection == ImGuiSortDirection_Descending )
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
const auto hle = m_worker.HasZoneExtra( *lhs );
|
||||
const auto hre = m_worker.HasZoneExtra( *rhs );
|
||||
if( !( hle & hre ) ) return hle > hre;
|
||||
return strcmp( m_worker.GetString( m_worker.GetZoneExtra( *lhs ).name ), m_worker.GetString( m_worker.GetZoneExtra( *rhs ).name ) ) < 0;
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
const auto hle = m_worker.HasZoneExtra( *lhs );
|
||||
const auto hre = m_worker.HasZoneExtra( *rhs );
|
||||
if( !( hle & hre ) ) return hle < hre;
|
||||
return strcmp( m_worker.GetString( m_worker.GetZoneExtra( *lhs ).name ), m_worker.GetString( m_worker.GetZoneExtra( *rhs ).name ) ) > 0;
|
||||
} );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiListClipper clipper;
|
||||
clipper.Begin( zonesToIterate->size() );
|
||||
while( clipper.Step() )
|
||||
{
|
||||
for( auto i=clipper.DisplayStart; i<clipper.DisplayEnd; i++ )
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
auto ev = (*zonesToIterate)[i].get();
|
||||
const auto end = m_worker.GetZoneEndDirect( *ev );
|
||||
int64_t timespan;
|
||||
if( m_findZone.runningTime )
|
||||
{
|
||||
const auto ctx = m_worker.GetContextSwitchData( GetZoneThread( *ev ) );
|
||||
uint64_t cnt;
|
||||
GetZoneRunningTime( ctx, *ev, timespan, cnt );
|
||||
}
|
||||
else
|
||||
{
|
||||
timespan = end - ev->Start();
|
||||
if( m_findZone.selfTime ) timespan -= GetZoneChildTimeFast( *ev );
|
||||
}
|
||||
|
||||
ImGui::PushID( ev );
|
||||
if( m_zoneHover == ev ) ImGui::PushStyleColor( ImGuiCol_Text, ImVec4( 0, 1, 0, 1 ) );
|
||||
if( ImGui::Selectable( TimeToStringExact( ev->Start() ), m_zoneInfoWindow == ev, ImGuiSelectableFlags_SpanAllColumns ) )
|
||||
{
|
||||
ShowZoneInfo( *ev );
|
||||
}
|
||||
if( ImGui::IsItemHovered() )
|
||||
{
|
||||
m_zoneHighlight = ev;
|
||||
if( IsMouseClicked( 2 ) )
|
||||
{
|
||||
ZoomToZone( *ev );
|
||||
}
|
||||
ZoneTooltip( *ev );
|
||||
m_zoneHover2 = ev;
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted( TimeToString( timespan ) );
|
||||
ImGui::TableNextColumn();
|
||||
if( m_worker.HasZoneExtra( *ev ) )
|
||||
{
|
||||
const auto& extra = m_worker.GetZoneExtra( *ev );
|
||||
if( extra.name.Active() )
|
||||
{
|
||||
ImGui::TextUnformatted( m_worker.GetString( extra.name ) );
|
||||
}
|
||||
}
|
||||
if( m_zoneHover == ev ) ImGui::PopStyleColor();
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
void View::DrawSamplesStatistics(Vector<SymList>& data, int64_t timeRange, AccumulationMode accumulationMode)
|
||||
{
|
||||
static unordered_flat_map<uint64_t, SymList> inlineMap;
|
||||
|
@ -68,6 +68,181 @@ uint64_t View::GetSelectionTarget( const Worker::ZoneThreadData& ev, FindZone::G
|
||||
}
|
||||
}
|
||||
|
||||
void View::DrawZoneList( int id, const Vector<short_ptr<ZoneEvent>>& zones )
|
||||
{
|
||||
const auto zsz = zones.size();
|
||||
char buf[32];
|
||||
sprintf( buf, "%i##zonelist", id );
|
||||
if( !ImGui::BeginTable( buf, 3, ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Resizable | ImGuiTableFlags_Hideable | ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_Sortable | ImGuiTableFlags_ScrollY, ImVec2( 0, ImGui::GetTextLineHeightWithSpacing() * std::min<size_t>( zsz + 1, 15 ) ) ) ) return;
|
||||
ImGui::TableSetupScrollFreeze( 0, 1 );
|
||||
ImGui::TableSetupColumn( "Time from start" );
|
||||
ImGui::TableSetupColumn( "Execution time", ImGuiTableColumnFlags_PreferSortDescending );
|
||||
ImGui::TableSetupColumn( "Name", ImGuiTableColumnFlags_NoSort );
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
const Vector<short_ptr<ZoneEvent>>* zonesToIterate = &zones;
|
||||
Vector<short_ptr<ZoneEvent>> sortedZones;
|
||||
|
||||
const auto& sortspec = *ImGui::TableGetSortSpecs()->Specs;
|
||||
if( sortspec.ColumnIndex != 0 || sortspec.SortDirection != ImGuiSortDirection_Ascending )
|
||||
{
|
||||
zonesToIterate = &sortedZones;
|
||||
sortedZones.reserve_and_use( zones.size() );
|
||||
memcpy( sortedZones.data(), zones.data(), zones.size() * sizeof( decltype( *zones.begin() ) ) );
|
||||
|
||||
switch( sortspec.ColumnIndex )
|
||||
{
|
||||
case 0:
|
||||
assert( sortspec.SortDirection != ImGuiSortDirection_Descending );
|
||||
std::reverse( sortedZones.begin(), sortedZones.end() );
|
||||
break;
|
||||
case 1:
|
||||
if( m_findZone.selfTime )
|
||||
{
|
||||
if( sortspec.SortDirection == ImGuiSortDirection_Descending )
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
return m_worker.GetZoneEndDirect( *lhs ) - lhs->Start() - this->GetZoneChildTimeFast( *lhs ) >
|
||||
m_worker.GetZoneEndDirect( *rhs ) - rhs->Start() - this->GetZoneChildTimeFast( *rhs );
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
return m_worker.GetZoneEndDirect( *lhs ) - lhs->Start() - this->GetZoneChildTimeFast( *lhs ) <
|
||||
m_worker.GetZoneEndDirect( *rhs ) - rhs->Start() - this->GetZoneChildTimeFast( *rhs );
|
||||
} );
|
||||
}
|
||||
}
|
||||
else if( m_findZone.runningTime )
|
||||
{
|
||||
if( sortspec.SortDirection == ImGuiSortDirection_Descending )
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
const auto ctx0 = m_worker.GetContextSwitchData( GetZoneThread( *lhs ) );
|
||||
const auto ctx1 = m_worker.GetContextSwitchData( GetZoneThread( *rhs ) );
|
||||
int64_t t0, t1;
|
||||
uint64_t c0, c1;
|
||||
GetZoneRunningTime( ctx0, *lhs, t0, c0 );
|
||||
GetZoneRunningTime( ctx1, *rhs, t1, c1 );
|
||||
return t0 > t1;
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
const auto ctx0 = m_worker.GetContextSwitchData( GetZoneThread( *lhs ) );
|
||||
const auto ctx1 = m_worker.GetContextSwitchData( GetZoneThread( *rhs ) );
|
||||
int64_t t0, t1;
|
||||
uint64_t c0, c1;
|
||||
GetZoneRunningTime( ctx0, *lhs, t0, c0 );
|
||||
GetZoneRunningTime( ctx1, *rhs, t1, c1 );
|
||||
return t0 < t1;
|
||||
} );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( sortspec.SortDirection == ImGuiSortDirection_Descending )
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
return m_worker.GetZoneEndDirect( *lhs ) - lhs->Start() > m_worker.GetZoneEndDirect( *rhs ) - rhs->Start();
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
return m_worker.GetZoneEndDirect( *lhs ) - lhs->Start() < m_worker.GetZoneEndDirect( *rhs ) - rhs->Start();
|
||||
} );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if( sortspec.SortDirection == ImGuiSortDirection_Descending )
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
const auto hle = m_worker.HasZoneExtra( *lhs );
|
||||
const auto hre = m_worker.HasZoneExtra( *rhs );
|
||||
if( !( hle & hre ) ) return hle > hre;
|
||||
return strcmp( m_worker.GetString( m_worker.GetZoneExtra( *lhs ).name ), m_worker.GetString( m_worker.GetZoneExtra( *rhs ).name ) ) < 0;
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) {
|
||||
const auto hle = m_worker.HasZoneExtra( *lhs );
|
||||
const auto hre = m_worker.HasZoneExtra( *rhs );
|
||||
if( !( hle & hre ) ) return hle < hre;
|
||||
return strcmp( m_worker.GetString( m_worker.GetZoneExtra( *lhs ).name ), m_worker.GetString( m_worker.GetZoneExtra( *rhs ).name ) ) > 0;
|
||||
} );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiListClipper clipper;
|
||||
clipper.Begin( zonesToIterate->size() );
|
||||
while( clipper.Step() )
|
||||
{
|
||||
for( auto i=clipper.DisplayStart; i<clipper.DisplayEnd; i++ )
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
auto ev = (*zonesToIterate)[i].get();
|
||||
const auto end = m_worker.GetZoneEndDirect( *ev );
|
||||
int64_t timespan;
|
||||
if( m_findZone.runningTime )
|
||||
{
|
||||
const auto ctx = m_worker.GetContextSwitchData( GetZoneThread( *ev ) );
|
||||
uint64_t cnt;
|
||||
GetZoneRunningTime( ctx, *ev, timespan, cnt );
|
||||
}
|
||||
else
|
||||
{
|
||||
timespan = end - ev->Start();
|
||||
if( m_findZone.selfTime ) timespan -= GetZoneChildTimeFast( *ev );
|
||||
}
|
||||
|
||||
ImGui::PushID( ev );
|
||||
if( m_zoneHover == ev ) ImGui::PushStyleColor( ImGuiCol_Text, ImVec4( 0, 1, 0, 1 ) );
|
||||
if( ImGui::Selectable( TimeToStringExact( ev->Start() ), m_zoneInfoWindow == ev, ImGuiSelectableFlags_SpanAllColumns ) )
|
||||
{
|
||||
ShowZoneInfo( *ev );
|
||||
}
|
||||
if( ImGui::IsItemHovered() )
|
||||
{
|
||||
m_zoneHighlight = ev;
|
||||
if( IsMouseClicked( 2 ) )
|
||||
{
|
||||
ZoomToZone( *ev );
|
||||
}
|
||||
ZoneTooltip( *ev );
|
||||
m_zoneHover2 = ev;
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted( TimeToString( timespan ) );
|
||||
ImGui::TableNextColumn();
|
||||
if( m_worker.HasZoneExtra( *ev ) )
|
||||
{
|
||||
const auto& extra = m_worker.GetZoneExtra( *ev );
|
||||
if( extra.name.Active() )
|
||||
{
|
||||
ImGui::TextUnformatted( m_worker.GetString( extra.name ) );
|
||||
}
|
||||
}
|
||||
if( m_zoneHover == ev ) ImGui::PopStyleColor();
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
void View::DrawFindZone()
|
||||
{
|
||||
if( m_shortcut == ShortcutAction::OpenFind ) ImGui::SetNextWindowFocus();
|
||||
|
Loading…
Reference in New Issue
Block a user