1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Update item counts in thread list.

This commit is contained in:
Bartosz Taudul 2018-03-04 23:17:36 +01:00
parent 3dd14c9e01
commit f510d8d2e7
2 changed files with 32 additions and 6 deletions

View File

@ -2708,7 +2708,6 @@ void View::DrawFindZone()
if( v.second != tmp )
{
v.second = tmp;
m_findZone.result.clear();
RecalcFindMatches();
}
}
@ -3011,14 +3010,15 @@ void View::DrawFindZone()
ImGui::Separator();
ImGui::Text( "Found zones:" );
int idx = 0;
for( auto& v : m_findZone.result )
for( size_t i=0; i<m_findZone.result.size(); i++ )
{
ImGui::PushID( idx++ );
auto& v = m_findZone.result[i];
ImGui::PushID( int( i ) );
const bool expand = ImGui::TreeNode( m_worker.GetThreadString( v->id ) );
ImGui::PopID();
ImGui::SameLine();
ImGui::TextColored( ImVec4( 0.5f, 0.5f, 0.5f, 1.0f ), "(%s)", RealToString( v->timeline.size(), true ) );
ImGui::TextColored( ImVec4( 0.5f, 0.5f, 0.5f, 1.0f ), "(%s)", RealToString( m_findZone.counts[i], true ) );
if( expand )
{
@ -3032,6 +3032,7 @@ void View::DrawFindZone()
ImGui::NextColumn();
ImGui::Separator();
uint32_t cnt = 0;
for( auto& ev : v->timeline )
{
const auto end = m_worker.GetZoneEnd( *ev );
@ -3069,10 +3070,29 @@ void View::DrawFindZone()
ImGui::NextColumn();
ImGui::PopID();
cnt++;
}
ImGui::Columns( 1 );
ImGui::Separator();
ImGui::TreePop();
m_findZone.counts[i] = cnt;
}
else
{
auto cnt = uint32_t( v->timeline.size() );
if( m_findZone.highlight.active )
{
for( auto& ev : v->timeline )
{
const auto end = m_worker.GetZoneEnd( *ev );
const auto timespan = end - ev->start;
const auto s = std::min( m_findZone.highlight.start, m_findZone.highlight.end );
const auto e = std::max( m_findZone.highlight.start, m_findZone.highlight.end );
if( timespan < s || timespan > e ) cnt--;
}
}
m_findZone.counts[i] = cnt;
}
}
}
@ -3329,6 +3349,9 @@ void View::FindZones()
void View::RecalcFindMatches()
{
m_findZone.result.clear();
m_findZone.counts.clear();
for( const auto& v : m_worker.GetThreadData() )
{
auto thrOut = std::make_unique<ThreadData>();
@ -3337,7 +3360,8 @@ void View::RecalcFindMatches()
if( !thrOut->timeline.empty() )
{
thrOut->id = v->id;
m_findZone.result.push_back( std::move( thrOut ) );
m_findZone.counts.emplace_back( thrOut->timeline.size() );
m_findZone.result.emplace_back( std::move( thrOut ) );
}
}
}

View File

@ -169,6 +169,7 @@ 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;
@ -181,6 +182,7 @@ private:
{
result.clear();
match.clear();
counts.clear();
highlight.active = false;
}
} m_findZone;