1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Implement self time in find zone menu.

This commit is contained in:
Bartosz Taudul 2019-01-23 14:25:45 +01:00
parent 92766430d9
commit 7f015b1b24

View File

@ -4833,9 +4833,9 @@ void View::DrawFindZone()
auto& zoneData = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] ); auto& zoneData = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] );
auto& zones = zoneData.zones; auto& zones = zoneData.zones;
const auto tmin = zoneData.min; const auto tmin = m_findZone.selfTime ? zoneData.selfMin : zoneData.min;
const auto tmax = zoneData.max; const auto tmax = m_findZone.selfTime ? zoneData.selfMax : zoneData.max;
const auto timeTotal = zoneData.total; const auto timeTotal = m_findZone.selfTime ? zoneData.selfTotal : zoneData.total;
const auto zsz = zones.size(); const auto zsz = zones.size();
if( m_findZone.sortedNum != zsz ) if( m_findZone.sortedNum != zsz )
@ -4844,13 +4844,27 @@ void View::DrawFindZone()
vec.reserve( zsz ); vec.reserve( zsz );
int64_t total = m_findZone.total; int64_t total = m_findZone.total;
size_t i; size_t i;
for( i=m_findZone.sortedNum; i<zsz; i++ ) if( m_findZone.selfTime )
{ {
auto& zone = *zones[i].zone; for( i=m_findZone.sortedNum; i<zsz; i++ )
if( zone.end < 0 ) break; {
const auto t = zone.end - zone.start; auto& zone = *zones[i].zone;
vec.emplace_back( t ); if( zone.end < 0 ) break;
total += t; const auto t = zone.end - zone.start - GetZoneChildTimeFast( zone );
vec.emplace_back( t );
total += t;
}
}
else
{
for( i=m_findZone.sortedNum; i<zsz; i++ )
{
auto& zone = *zones[i].zone;
if( zone.end < 0 ) break;
const auto t = zone.end - zone.start;
vec.emplace_back( t );
total += t;
}
} }
auto mid = vec.begin() + m_findZone.sortedNum; auto mid = vec.begin() + m_findZone.sortedNum;
pdqsort_branchless( mid, vec.end() ); pdqsort_branchless( mid, vec.end() );
@ -4873,16 +4887,32 @@ void View::DrawFindZone()
vec.reserve( zsz ); vec.reserve( zsz );
auto act = m_findZone.selSortActive; auto act = m_findZone.selSortActive;
int64_t total = m_findZone.selTotal; int64_t total = m_findZone.selTotal;
size_t i; if( m_findZone.selfTime )
for( i=m_findZone.selSortNum; i<m_findZone.sortedNum; i++ )
{ {
auto& ev = zones[i]; for( size_t i=m_findZone.selSortNum; i<m_findZone.sortedNum; i++ )
if( selGroup == GetSelectionTarget( ev, groupBy ) )
{ {
const auto t = ev.zone->end - ev.zone->start; auto& ev = zones[i];
vec.emplace_back( t ); if( selGroup == GetSelectionTarget( ev, groupBy ) )
act++; {
total += t; const auto t = ev.zone->end - ev.zone->start - GetZoneChildTimeFast( *ev.zone );
vec.emplace_back( t );
act++;
total += t;
}
}
}
else
{
for( size_t i=m_findZone.selSortNum; i<m_findZone.sortedNum; i++ )
{
auto& ev = zones[i];
if( selGroup == GetSelectionTarget( ev, groupBy ) )
{
const auto t = ev.zone->end - ev.zone->start;
vec.emplace_back( t );
act++;
total += t;
}
} }
} }
auto mid = vec.begin() + m_findZone.selSortActive; auto mid = vec.begin() + m_findZone.selSortActive;
@ -5492,12 +5522,13 @@ void View::DrawFindZone()
if( ev.zone->end < 0 ) break; if( ev.zone->end < 0 ) break;
const auto end = m_worker.GetZoneEndDirect( *ev.zone ); const auto end = m_worker.GetZoneEndDirect( *ev.zone );
const auto timespan = end - ev.zone->start; auto timespan = end - ev.zone->start;
if( timespan == 0 ) if( timespan == 0 )
{ {
processed++; processed++;
continue; continue;
} }
if( m_findZone.selfTime ) timespan -= GetZoneChildTimeFast( *ev.zone );
if( highlightActive ) if( highlightActive )
{ {
@ -5622,7 +5653,8 @@ void View::DrawFindZone()
for( auto& ev : v->second.zones ) for( auto& ev : v->second.zones )
{ {
const auto end = m_worker.GetZoneEndDirect( *ev ); const auto end = m_worker.GetZoneEndDirect( *ev );
const auto timespan = end - ev->start; auto timespan = end - ev->start;
if( m_findZone.selfTime ) timespan -= GetZoneChildTimeFast( *ev );
ImGui::PushID( ev ); ImGui::PushID( ev );
if( ImGui::Selectable( TimeToString( ev->start - m_worker.GetTimeBegin() ), m_zoneInfoWindow == ev, ImGuiSelectableFlags_SpanAllColumns ) ) if( ImGui::Selectable( TimeToString( ev->start - m_worker.GetTimeBegin() ), m_zoneInfoWindow == ev, ImGuiSelectableFlags_SpanAllColumns ) )