From 7f015b1b2419fc9e0f9d4d8efa9aca8a0af7fe9a Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 23 Jan 2019 14:25:45 +0100 Subject: [PATCH] Implement self time in find zone menu. --- server/TracyView.cpp | 70 ++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 19 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 24c7e939..e8c666f7 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -4833,9 +4833,9 @@ void View::DrawFindZone() auto& zoneData = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] ); auto& zones = zoneData.zones; - const auto tmin = zoneData.min; - const auto tmax = zoneData.max; - const auto timeTotal = zoneData.total; + const auto tmin = m_findZone.selfTime ? zoneData.selfMin : zoneData.min; + const auto tmax = m_findZone.selfTime ? zoneData.selfMax : zoneData.max; + const auto timeTotal = m_findZone.selfTime ? zoneData.selfTotal : zoneData.total; const auto zsz = zones.size(); if( m_findZone.sortedNum != zsz ) @@ -4844,13 +4844,27 @@ void View::DrawFindZone() vec.reserve( zsz ); int64_t total = m_findZone.total; size_t i; - for( i=m_findZone.sortedNum; iend - ev.zone->start; - vec.emplace_back( t ); - act++; - total += t; + auto& ev = zones[i]; + if( selGroup == GetSelectionTarget( ev, groupBy ) ) + { + 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; iend - ev.zone->start; + vec.emplace_back( t ); + act++; + total += t; + } } } auto mid = vec.begin() + m_findZone.selSortActive; @@ -5492,12 +5522,13 @@ void View::DrawFindZone() if( ev.zone->end < 0 ) break; const auto end = m_worker.GetZoneEndDirect( *ev.zone ); - const auto timespan = end - ev.zone->start; + auto timespan = end - ev.zone->start; if( timespan == 0 ) { processed++; continue; } + if( m_findZone.selfTime ) timespan -= GetZoneChildTimeFast( *ev.zone ); if( highlightActive ) { @@ -5622,7 +5653,8 @@ void View::DrawFindZone() for( auto& ev : v->second.zones ) { 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 ); if( ImGui::Selectable( TimeToString( ev->start - m_worker.GetTimeBegin() ), m_zoneInfoWindow == ev, ImGuiSelectableFlags_SpanAllColumns ) )