mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Live updates of find zone data.
TODO: found zones list. Currently only histogram view is available.
This commit is contained in:
parent
c807b3f7ef
commit
746df21ad9
@ -2714,17 +2714,6 @@ void View::DrawFindZone()
|
||||
m_findZone.Reset();
|
||||
}
|
||||
|
||||
if( ImGui::TreeNode( "Options" ) )
|
||||
{
|
||||
ImGui::InputInt( "max zones per thread", &m_findZone.maxZonesPerThread );
|
||||
ImGui::SameLine();
|
||||
DrawHelpMarker( "-1 for unlimited.\nHigh value or unlimited zone search may lead to performance issues." );
|
||||
ImGui::InputInt( "max depth", &m_findZone.maxDepth );
|
||||
ImGui::SameLine();
|
||||
DrawHelpMarker( "-1 for unlimited." );
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if( findClicked )
|
||||
{
|
||||
m_findZone.Reset();
|
||||
@ -2746,18 +2735,11 @@ void View::DrawFindZone()
|
||||
ImGui::SameLine();
|
||||
ImGui::TextColored( ImVec4( 0.5, 0.5, 0.5, 1 ), "%s:%i", m_worker.GetString( srcloc.file ), srcloc.line );
|
||||
ImGui::PopID();
|
||||
if( v.second != tmp )
|
||||
{
|
||||
v.second = tmp;
|
||||
RecalcFindMatches();
|
||||
}
|
||||
if( v.second != tmp ) v.second = tmp;
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
if( !m_findZone.result.empty() )
|
||||
{
|
||||
ImGui::Separator();
|
||||
|
||||
if( ImGui::TreeNode( "Histogram" ) )
|
||||
@ -2767,16 +2749,23 @@ void View::DrawFindZone()
|
||||
int64_t tmin = std::numeric_limits<int64_t>::max();
|
||||
int64_t tmax = std::numeric_limits<int64_t>::min();
|
||||
|
||||
for( auto& v : m_findZone.result )
|
||||
for( auto& v : m_findZone.match )
|
||||
{
|
||||
for( auto& ev : v->timeline )
|
||||
if( !v.second ) continue;
|
||||
auto& zones = m_worker.GetZonesForSourceLocation( v.first );
|
||||
for( auto& ev : zones )
|
||||
{
|
||||
const auto timeSpan = m_worker.GetZoneEnd( *ev ) - ev->start;
|
||||
if( timeSpan != 0 )
|
||||
{
|
||||
tmin = std::min( tmin, timeSpan );
|
||||
tmax = std::max( tmax, timeSpan );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( tmin != std::numeric_limits<int64_t>::max() )
|
||||
{
|
||||
ImGui::Checkbox( "Log values", &m_findZone.logVal );
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox( "Log time", &m_findZone.logTime );
|
||||
@ -2818,11 +2807,15 @@ void View::DrawFindZone()
|
||||
{
|
||||
const auto tMinLog = log10( tmin );
|
||||
const auto idt = numBins / ( log10( tmax ) - tMinLog );
|
||||
for( auto& v : m_findZone.result )
|
||||
for( auto& v : m_findZone.match )
|
||||
{
|
||||
for( auto& ev : v->timeline )
|
||||
if( !v.second ) continue;
|
||||
auto& zones = m_worker.GetZonesForSourceLocation( v.first );
|
||||
for( auto& ev : zones )
|
||||
{
|
||||
const auto timeSpan = m_worker.GetZoneEnd( *ev ) - ev->start;
|
||||
if( timeSpan != 0 )
|
||||
{
|
||||
const auto bin = std::min( numBins - 1, int64_t( ( log10( timeSpan ) - tMinLog ) * idt ) );
|
||||
bins[bin]++;
|
||||
binTime[bin] += timeSpan;
|
||||
@ -2830,14 +2823,19 @@ void View::DrawFindZone()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto idt = numBins / dt;
|
||||
for( auto& v : m_findZone.result )
|
||||
for( auto& v : m_findZone.match )
|
||||
{
|
||||
for( auto& ev : v->timeline )
|
||||
if( !v.second ) continue;
|
||||
auto& zones = m_worker.GetZonesForSourceLocation( v.first );
|
||||
for( auto& ev : zones )
|
||||
{
|
||||
const auto timeSpan = m_worker.GetZoneEnd( *ev ) - ev->start;
|
||||
if( timeSpan != 0 )
|
||||
{
|
||||
const auto bin = std::min( numBins - 1, int64_t( ( timeSpan - tmin ) * idt ) );
|
||||
bins[bin]++;
|
||||
binTime[bin] += timeSpan;
|
||||
@ -2846,31 +2844,41 @@ void View::DrawFindZone()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_findZone.logTime )
|
||||
{
|
||||
const auto tMinLog = log10( tmin );
|
||||
const auto idt = numBins / ( log10( tmax ) - tMinLog );
|
||||
for( auto& v : m_findZone.result )
|
||||
for( auto& v : m_findZone.match )
|
||||
{
|
||||
for( auto& ev : v->timeline )
|
||||
if( !v.second ) continue;
|
||||
auto& zones = m_worker.GetZonesForSourceLocation( v.first );
|
||||
for( auto& ev : zones )
|
||||
{
|
||||
const auto timeSpan = m_worker.GetZoneEnd( *ev ) - ev->start;
|
||||
if( timeSpan != 0 )
|
||||
{
|
||||
const auto bin = std::min( numBins - 1, int64_t( ( log10( timeSpan ) - tMinLog ) * idt ) );
|
||||
bins[bin]++;
|
||||
binTime[bin] += timeSpan;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto idt = numBins / dt;
|
||||
for( auto& v : m_findZone.result )
|
||||
for( auto& v : m_findZone.match )
|
||||
{
|
||||
for( auto& ev : v->timeline )
|
||||
if( !v.second ) continue;
|
||||
auto& zones = m_worker.GetZonesForSourceLocation( v.first );
|
||||
for( auto& ev : zones )
|
||||
{
|
||||
const auto timeSpan = m_worker.GetZoneEnd( *ev ) - ev->start;
|
||||
if( timeSpan != 0 )
|
||||
{
|
||||
const auto bin = std::min( numBins - 1, int64_t( ( timeSpan - tmin ) * idt ) );
|
||||
bins[bin]++;
|
||||
binTime[bin] += timeSpan;
|
||||
@ -2878,6 +2886,7 @@ void View::DrawFindZone()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int64_t timeTotal = binTime[0];
|
||||
int64_t maxVal;
|
||||
@ -3137,10 +3146,13 @@ void View::DrawFindZone()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
// TODO
|
||||
#if 0
|
||||
ImGui::Separator();
|
||||
ImGui::Text( "Found zones:" );
|
||||
|
||||
@ -3229,6 +3241,7 @@ void View::DrawFindZone()
|
||||
m_findZone.counts[i] = cnt;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
@ -3474,49 +3487,11 @@ void View::FindZones()
|
||||
|
||||
m_findZone.match.reserve( match.size() );
|
||||
for( auto& v : match )
|
||||
{
|
||||
if( !m_worker.GetZonesForSourceLocation( v ).empty() )
|
||||
{
|
||||
m_findZone.match.emplace( v, true );
|
||||
}
|
||||
|
||||
RecalcFindMatches();
|
||||
}
|
||||
|
||||
void View::RecalcFindMatches()
|
||||
{
|
||||
m_findZone.result.clear();
|
||||
m_findZone.counts.clear();
|
||||
|
||||
for( const auto& v : m_worker.GetThreadData() )
|
||||
{
|
||||
auto thrOut = std::make_unique<ThreadData>();
|
||||
RecalcFindMatches( v->timeline, thrOut->timeline, m_findZone.maxDepth );
|
||||
|
||||
if( !thrOut->timeline.empty() )
|
||||
{
|
||||
thrOut->id = v->id;
|
||||
m_findZone.counts.emplace_back( thrOut->timeline.size() );
|
||||
m_findZone.result.emplace_back( std::move( thrOut ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void View::RecalcFindMatches( const Vector<ZoneEvent*>& events, Vector<ZoneEvent*>& out, const int maxdepth )
|
||||
{
|
||||
for( auto& ev : events )
|
||||
{
|
||||
if( out.size() >= m_findZone.maxZonesPerThread ) break;
|
||||
if( m_worker.GetZoneEnd( *ev ) == ev->start ) continue;
|
||||
|
||||
auto it = m_findZone.match.find( ev->srcloc );
|
||||
if( it != m_findZone.match.end() && it->second )
|
||||
{
|
||||
out.push_back( ev );
|
||||
}
|
||||
|
||||
if( maxdepth != 0 )
|
||||
{
|
||||
RecalcFindMatches( ev->child, out, maxdepth - 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,8 +98,6 @@ private:
|
||||
const GpuEvent* GetZoneParent( const GpuEvent& zone ) const;
|
||||
|
||||
void FindZones();
|
||||
void RecalcFindMatches();
|
||||
void RecalcFindMatches( const Vector<ZoneEvent*> &events, Vector<ZoneEvent*> &out, const int maxdepth = 0 );
|
||||
|
||||
template <typename T>
|
||||
bool& Visible( const T* ptr )
|
||||
@ -168,12 +166,9 @@ private:
|
||||
|
||||
struct {
|
||||
bool show;
|
||||
std::vector<std::unique_ptr<ThreadData>> result;
|
||||
std::vector<uint32_t> counts;
|
||||
flat_hash_map<int32_t, bool> match;
|
||||
char pattern[1024] = { "" };
|
||||
int maxZonesPerThread = -1;
|
||||
int maxDepth = -1;
|
||||
bool logVal = false;
|
||||
bool logTime = false;
|
||||
bool cumulateTime = false;
|
||||
@ -181,7 +176,6 @@ private:
|
||||
|
||||
void Reset()
|
||||
{
|
||||
result.clear();
|
||||
match.clear();
|
||||
counts.clear();
|
||||
highlight.active = false;
|
||||
|
Loading…
Reference in New Issue
Block a user