1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 12:23:53 +00:00

Avoid useless work when there aren't any samples

This commit is contained in:
xavier 2021-09-05 11:04:45 +02:00
parent 1233b39b69
commit 41130d2a69
2 changed files with 29 additions and 7 deletions

View File

@ -10699,7 +10699,8 @@ void View::DrawFindZone()
SmallCheckbox( "Show zone time in frames", &m_findZone.showZoneInFrames );
ImGui::Separator();
if( ImGui::TreeNodeEx( "Samples", ImGuiTreeNodeFlags_None ) )
const bool hasSamples = m_worker.AreCallstackSamplesReady() && m_worker.GetCallstackSampleCount() > 0;
if( hasSamples && ImGui::TreeNodeEx( "Samples", ImGuiTreeNodeFlags_None ) )
{
{
ImGui::Checkbox( ICON_FA_STOPWATCH " Show time", &m_statSampleTime );
@ -10724,6 +10725,12 @@ void View::DrawFindZone()
}
}
if( !m_findZone.samplesCache.needZonesPerThread )
{
m_findZone.samplesCache.needZonesPerThread = true;
m_findZone.scheduleResetMatch = true;
}
if( m_findZone.samplesCache.scheduleUpdate && !m_findZone.scheduleResetMatch )
{
m_findZone.samplesCache.scheduleUpdate = false;
@ -10793,6 +10800,16 @@ void View::DrawFindZone()
ImGui::TreePop();
}
else
{
if( m_findZone.samplesCache.needZonesPerThread )
{
m_findZone.samplesCache.needZonesPerThread = false;
m_findZone.samplesCache.scheduleUpdate = false;
m_findZone.samplesCache.counts = Vector<SymList>();
m_findZone.samplesCache.threads = unordered_flat_map<uint16_t, Vector<short_ptr<ZoneEvent>> >();
}
}
ImGui::Separator();
ImGui::TextUnformatted( "Found zones:" );
@ -10953,6 +10970,9 @@ void View::DrawFindZone()
group->time += timespan;
group->zones.push_back_non_empty( ev.Zone() );
if( m_findZone.samplesCache.needZonesPerThread )
{
if( lastTid != ev.Thread() )
{
lastTid = ev.Thread();
@ -10962,6 +10982,7 @@ void View::DrawFindZone()
threadZones->push_back_non_empty( ev.Zone() );
m_findZone.samplesCache.scheduleUpdate = true;
}
}
m_findZone.processed = zptr - zones.data();
Vector<decltype( m_findZone.groups )::iterator> groups;

View File

@ -567,6 +567,7 @@ private:
Vector<SymList> counts;
int64_t timeRange = 0;
bool scheduleUpdate = false;
bool needZonesPerThread = false;
} samplesCache;
void Reset()