1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-03 14:03:52 +00:00

Only display results for a single source location match.

This commit is contained in:
Bartosz Taudul 2018-03-18 16:07:07 +01:00
parent 3207861869
commit af3559afed
2 changed files with 52 additions and 68 deletions

View File

@ -2732,14 +2732,12 @@ void View::DrawFindZone()
int idx = 0; int idx = 0;
for( auto& v : m_findZone.match ) for( auto& v : m_findZone.match )
{ {
auto& srcloc = m_worker.GetSourceLocation( v.first ); auto& srcloc = m_worker.GetSourceLocation( v );
bool tmp = v.second; ImGui::PushID( idx );
ImGui::PushID( idx++ ); ImGui::RadioButton( m_worker.GetString( srcloc.name.active ? srcloc.name : srcloc.function ), &m_findZone.selMatch, idx++ );
ImGui::Checkbox( m_worker.GetString( srcloc.name.active ? srcloc.name : srcloc.function ), &tmp );
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextColored( ImVec4( 0.5, 0.5, 0.5, 1 ), "%s:%i", m_worker.GetString( srcloc.file ), srcloc.line ); ImGui::TextColored( ImVec4( 0.5, 0.5, 0.5, 1 ), "%s:%i", m_worker.GetString( srcloc.file ), srcloc.line );
ImGui::PopID(); ImGui::PopID();
if( v.second != tmp ) v.second = tmp;
} }
ImGui::TreePop(); ImGui::TreePop();
} }
@ -2753,18 +2751,14 @@ void View::DrawFindZone()
int64_t tmin = std::numeric_limits<int64_t>::max(); int64_t tmin = std::numeric_limits<int64_t>::max();
int64_t tmax = std::numeric_limits<int64_t>::min(); int64_t tmax = std::numeric_limits<int64_t>::min();
for( auto& v : m_findZone.match ) auto& zones = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] );
for( auto& ev : zones )
{ {
if( !v.second ) continue; const auto timeSpan = m_worker.GetZoneEndDirect( *ev ) - ev->start;
auto& zones = m_worker.GetZonesForSourceLocation( v.first ); if( timeSpan != 0 )
for( auto& ev : zones )
{ {
const auto timeSpan = m_worker.GetZoneEndDirect( *ev ) - ev->start; tmin = std::min( tmin, timeSpan );
if( timeSpan != 0 ) tmax = std::max( tmax, timeSpan );
{
tmin = std::min( tmin, timeSpan );
tmax = std::max( tmax, timeSpan );
}
} }
} }
@ -2811,40 +2805,32 @@ void View::DrawFindZone()
{ {
const auto tMinLog = log10( tmin ); const auto tMinLog = log10( tmin );
const auto idt = numBins / ( log10( tmax ) - tMinLog ); const auto idt = numBins / ( log10( tmax ) - tMinLog );
for( auto& v : m_findZone.match ) auto& zones = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] );
for( auto& ev : zones )
{ {
if( !v.second ) continue; const auto timeSpan = m_worker.GetZoneEndDirect( *ev ) - ev->start;
auto& zones = m_worker.GetZonesForSourceLocation( v.first ); if( timeSpan != 0 )
for( auto& ev : zones )
{ {
const auto timeSpan = m_worker.GetZoneEndDirect( *ev ) - ev->start; const auto bin = std::min( numBins - 1, int64_t( ( log10( timeSpan ) - tMinLog ) * idt ) );
if( timeSpan != 0 ) bins[bin]++;
{ binTime[bin] += timeSpan;
const auto bin = std::min( numBins - 1, int64_t( ( log10( timeSpan ) - tMinLog ) * idt ) ); if( timeSpan >= s && timeSpan <= e ) selectionTime += timeSpan;
bins[bin]++;
binTime[bin] += timeSpan;
if( timeSpan >= s && timeSpan <= e ) selectionTime += timeSpan;
}
} }
} }
} }
else else
{ {
const auto idt = numBins / dt; const auto idt = numBins / dt;
for( auto& v : m_findZone.match ) auto& zones = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] );
for( auto& ev : zones )
{ {
if( !v.second ) continue; const auto timeSpan = m_worker.GetZoneEndDirect( *ev ) - ev->start;
auto& zones = m_worker.GetZonesForSourceLocation( v.first ); if( timeSpan != 0 )
for( auto& ev : zones )
{ {
const auto timeSpan = m_worker.GetZoneEndDirect( *ev ) - ev->start; const auto bin = std::min( numBins - 1, int64_t( ( timeSpan - tmin ) * idt ) );
if( timeSpan != 0 ) bins[bin]++;
{ binTime[bin] += timeSpan;
const auto bin = std::min( numBins - 1, int64_t( ( timeSpan - tmin ) * idt ) ); if( timeSpan >= s && timeSpan <= e ) selectionTime += timeSpan;
bins[bin]++;
binTime[bin] += timeSpan;
if( timeSpan >= s && timeSpan <= e ) selectionTime += timeSpan;
}
} }
} }
} }
@ -2855,38 +2841,30 @@ void View::DrawFindZone()
{ {
const auto tMinLog = log10( tmin ); const auto tMinLog = log10( tmin );
const auto idt = numBins / ( log10( tmax ) - tMinLog ); const auto idt = numBins / ( log10( tmax ) - tMinLog );
for( auto& v : m_findZone.match ) auto& zones = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] );
for( auto& ev : zones )
{ {
if( !v.second ) continue; const auto timeSpan = m_worker.GetZoneEndDirect( *ev ) - ev->start;
auto& zones = m_worker.GetZonesForSourceLocation( v.first ); if( timeSpan != 0 )
for( auto& ev : zones )
{ {
const auto timeSpan = m_worker.GetZoneEndDirect( *ev ) - ev->start; const auto bin = std::min( numBins - 1, int64_t( ( log10( timeSpan ) - tMinLog ) * idt ) );
if( timeSpan != 0 ) bins[bin]++;
{ binTime[bin] += timeSpan;
const auto bin = std::min( numBins - 1, int64_t( ( log10( timeSpan ) - tMinLog ) * idt ) );
bins[bin]++;
binTime[bin] += timeSpan;
}
} }
} }
} }
else else
{ {
const auto idt = numBins / dt; const auto idt = numBins / dt;
for( auto& v : m_findZone.match ) auto& zones = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] );
for( auto& ev : zones )
{ {
if( !v.second ) continue; const auto timeSpan = m_worker.GetZoneEndDirect( *ev ) - ev->start;
auto& zones = m_worker.GetZonesForSourceLocation( v.first ); if( timeSpan != 0 )
for( auto& ev : zones )
{ {
const auto timeSpan = m_worker.GetZoneEndDirect( *ev ) - ev->start; const auto bin = std::min( numBins - 1, int64_t( ( timeSpan - tmin ) * idt ) );
if( timeSpan != 0 ) bins[bin]++;
{ binTime[bin] += timeSpan;
const auto bin = std::min( numBins - 1, int64_t( ( timeSpan - tmin ) * idt ) );
bins[bin]++;
binTime[bin] += timeSpan;
}
} }
} }
} }
@ -3488,15 +3466,19 @@ const GpuEvent* View::GetZoneParent( const GpuEvent& zone ) const
#ifndef TRACY_NO_STATISTICS #ifndef TRACY_NO_STATISTICS
void View::FindZones() void View::FindZones()
{ {
const auto match = m_worker.GetMatchingSourceLocation( m_findZone.pattern ); m_findZone.match = m_worker.GetMatchingSourceLocation( m_findZone.pattern );
if( match.empty() ) return; if( m_findZone.match.empty() ) return;
m_findZone.match.reserve( match.size() ); auto it = m_findZone.match.begin();
for( auto& v : match ) while( it != m_findZone.match.end() )
{ {
if( !m_worker.GetZonesForSourceLocation( v ).empty() ) if( m_worker.GetZonesForSourceLocation( *it ).empty() )
{ {
m_findZone.match.emplace( v, true ); it = m_findZone.match.erase( it );
}
else
{
++it;
} }
} }
} }

View File

@ -169,7 +169,8 @@ private:
struct { struct {
bool show; bool show;
std::vector<uint32_t> counts; std::vector<uint32_t> counts;
flat_hash_map<int32_t, bool> match; std::vector<int32_t> match;
int selMatch = 0;
char pattern[1024] = { "" }; char pattern[1024] = { "" };
bool logVal = false; bool logVal = false;
bool logTime = false; bool logTime = false;
@ -180,6 +181,7 @@ private:
{ {
match.clear(); match.clear();
counts.clear(); counts.clear();
selMatch = 0;
highlight.active = false; highlight.active = false;
} }
} m_findZone; } m_findZone;