mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Sort source location zones only when needed.
This commit is contained in:
parent
befeffb61e
commit
cb004e9cc0
@ -1980,6 +1980,7 @@ void View::DrawFrames()
|
||||
if( m_worker.AreSourceLocationZonesReady() && m_findZone.show && m_findZone.showZoneInFrames && !m_findZone.match.empty() )
|
||||
{
|
||||
auto& zoneData = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] );
|
||||
zoneData.zones.ensure_sorted();
|
||||
auto begin = zoneData.zones.begin();
|
||||
while( i < onScreen && m_vd.frameStart + idx < total )
|
||||
{
|
||||
@ -9927,11 +9928,12 @@ void View::DrawFindZone()
|
||||
ImGui::Separator();
|
||||
|
||||
auto& zoneData = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] );
|
||||
auto& zones = zoneData.zones;
|
||||
zones.ensure_sorted();
|
||||
if( ImGui::TreeNodeEx( "Histogram", ImGuiTreeNodeFlags_DefaultOpen ) )
|
||||
{
|
||||
const auto ty = ImGui::GetFontSize();
|
||||
|
||||
auto& zones = zoneData.zones;
|
||||
int64_t tmin = m_findZone.tmin;
|
||||
int64_t tmax = m_findZone.tmax;
|
||||
int64_t total = m_findZone.total;
|
||||
@ -10940,7 +10942,6 @@ void View::DrawFindZone()
|
||||
ImGui::SameLine();
|
||||
DrawHelpMarker( "Mean time per call" );
|
||||
|
||||
auto& zones = zoneData.zones;
|
||||
const auto hmin = std::min( m_findZone.highlight.start, m_findZone.highlight.end );
|
||||
const auto hmax = std::max( m_findZone.highlight.start, m_findZone.highlight.end );
|
||||
const auto groupBy = m_findZone.groupBy;
|
||||
@ -12061,6 +12062,8 @@ void View::DrawCompare()
|
||||
auto& zoneData1 = m_compare.second->GetZonesForSourceLocation( m_compare.match[1][m_compare.selMatch[1]] );
|
||||
auto& zones0 = zoneData0.zones;
|
||||
auto& zones1 = zoneData1.zones;
|
||||
zones0.ensure_sorted();
|
||||
zones1.ensure_sorted();
|
||||
|
||||
tmin = std::min( zoneData0.min, zoneData1.min );
|
||||
tmax = std::max( zoneData0.max, zoneData1.max );
|
||||
@ -18374,7 +18377,7 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const
|
||||
if( m_worker.AreSourceLocationZonesReady() )
|
||||
{
|
||||
auto& slz = m_worker.GetZonesForSourceLocation( zone.SrcLoc() );
|
||||
if( !slz.zones.empty() )
|
||||
if( !slz.zones.empty() && slz.zones.is_sorted() )
|
||||
{
|
||||
auto it = std::lower_bound( slz.zones.begin(), slz.zones.end(), zone.Start(), [] ( const auto& lhs, const auto& rhs ) { return lhs.Zone()->Start() < rhs; } );
|
||||
if( it != slz.zones.end() && it->Zone() == &zone )
|
||||
@ -18457,7 +18460,7 @@ bool View::IsZoneReentry( const ZoneEvent& zone ) const
|
||||
if( m_worker.AreSourceLocationZonesReady() )
|
||||
{
|
||||
auto& slz = m_worker.GetZonesForSourceLocation( zone.SrcLoc() );
|
||||
if( !slz.zones.empty() )
|
||||
if( !slz.zones.empty() && slz.zones.is_sorted() )
|
||||
{
|
||||
auto it = std::lower_bound( slz.zones.begin(), slz.zones.end(), zone.Start(), [] ( const auto& lhs, const auto& rhs ) { return lhs.Zone()->Start() < rhs; } );
|
||||
if( it != slz.zones.end() && it->Zone() == &zone )
|
||||
@ -18582,7 +18585,7 @@ const ThreadData* View::GetZoneThreadData( const ZoneEvent& zone ) const
|
||||
if( m_worker.AreSourceLocationZonesReady() )
|
||||
{
|
||||
auto& slz = m_worker.GetZonesForSourceLocation( zone.SrcLoc() );
|
||||
if( !slz.zones.empty() )
|
||||
if( !slz.zones.empty() && slz.zones.is_sorted() )
|
||||
{
|
||||
auto it = std::lower_bound( slz.zones.begin(), slz.zones.end(), zone.Start(), [] ( const auto& lhs, const auto& rhs ) { return lhs.Zone()->Start() < rhs; } );
|
||||
if( it != slz.zones.end() && it->Zone() == &zone )
|
||||
|
@ -1948,6 +1948,8 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
|
||||
ProcessTimeline( countMap, t->timeline, m_data.localThreadCompress.DecompressMustRaw( t->id ) );
|
||||
}
|
||||
}
|
||||
std::lock_guard<std::mutex> lock( m_data.lock );
|
||||
m_data.sourceLocationZonesReady = true;
|
||||
} ) );
|
||||
|
||||
if( eventMask & EventType::Samples )
|
||||
@ -2093,17 +2095,6 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
|
||||
}
|
||||
|
||||
for( auto& job : jobs ) job.join();
|
||||
|
||||
for( auto& v : m_data.sourceLocationZones )
|
||||
{
|
||||
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
|
||||
if( !v.second.zones.is_sorted() ) v.second.zones.sort();
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lock( m_data.lock );
|
||||
m_data.sourceLocationZonesReady = true;
|
||||
}
|
||||
|
||||
m_backgroundDone.store( true, std::memory_order_relaxed );
|
||||
} );
|
||||
#else
|
||||
@ -2904,6 +2895,14 @@ std::vector<int16_t> Worker::GetMatchingSourceLocation( const char* query, bool
|
||||
}
|
||||
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
Worker::SourceLocationZones& Worker::GetZonesForSourceLocation( int16_t srcloc )
|
||||
{
|
||||
assert( AreSourceLocationZonesReady() );
|
||||
static SourceLocationZones empty;
|
||||
auto it = m_data.sourceLocationZones.find( srcloc );
|
||||
return it != m_data.sourceLocationZones.end() ? it->second : empty;
|
||||
}
|
||||
|
||||
const Worker::SourceLocationZones& Worker::GetZonesForSourceLocation( int16_t srcloc ) const
|
||||
{
|
||||
assert( AreSourceLocationZonesReady() );
|
||||
@ -4349,14 +4348,6 @@ void Worker::DoPostponedWork()
|
||||
m_data.newFramesWereReceived = false;
|
||||
}
|
||||
|
||||
if( m_data.sourceLocationZonesReady )
|
||||
{
|
||||
for( auto& slz : m_data.sourceLocationZones )
|
||||
{
|
||||
if( !slz.second.zones.is_sorted() ) slz.second.zones.sort();
|
||||
}
|
||||
}
|
||||
|
||||
if( m_data.newContextSwitchesReceived )
|
||||
{
|
||||
for( auto& td : m_data.threads )
|
||||
|
@ -566,6 +566,7 @@ public:
|
||||
std::vector<int16_t> GetMatchingSourceLocation( const char* query, bool ignoreCase ) const;
|
||||
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
SourceLocationZones& GetZonesForSourceLocation( int16_t srcloc );
|
||||
const SourceLocationZones& GetZonesForSourceLocation( int16_t srcloc ) const;
|
||||
const unordered_flat_map<int16_t, SourceLocationZones>& GetSourceLocationZones() const { return m_data.sourceLocationZones; }
|
||||
bool AreSourceLocationZonesReady() const { return m_data.sourceLocationZonesReady; }
|
||||
|
Loading…
Reference in New Issue
Block a user