mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Indicate zones with thread migration across CPU cores.
This commit is contained in:
parent
dc72010bd5
commit
4227d34599
@ -1228,6 +1228,7 @@ void View::DrawZones()
|
||||
draw->AddText( wpos + ImVec2( 0, offset ), 0xFFFFFFFF, GetThreadString( v->id ) );
|
||||
offset += ostep;
|
||||
|
||||
m_lastCpu = -1;
|
||||
const auto depth = DrawZoneLevel( v->timeline, hover, pxns, wpos, offset, 0 );
|
||||
|
||||
offset += ostep * ( depth + 1.2f );
|
||||
@ -1317,13 +1318,35 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
|
||||
if( ev.text->userText ) dmul++;
|
||||
}
|
||||
|
||||
bool migration = false;
|
||||
if( m_lastCpu != ev.cpu_start )
|
||||
{
|
||||
if( m_lastCpu != -1 )
|
||||
{
|
||||
migration = true;
|
||||
}
|
||||
m_lastCpu = ev.cpu_start;
|
||||
}
|
||||
|
||||
if( !ev.child.empty() )
|
||||
{
|
||||
const auto d = DrawZoneLevel( ev.child, hover, pxns, wpos, _offset, depth+1 );
|
||||
if( d > maxdepth ) maxdepth = d;
|
||||
}
|
||||
|
||||
if( ev.end != -1 && m_lastCpu != ev.cpu_end )
|
||||
{
|
||||
m_lastCpu = ev.cpu_end;
|
||||
migration = true;
|
||||
}
|
||||
|
||||
const auto tsz = ImGui::CalcTextSize( zoneName );
|
||||
const auto pr0 = ( ev.start - m_zvStart ) * pxns;
|
||||
const auto pr1 = ( end - m_zvStart ) * pxns;
|
||||
const auto px0 = std::max( pr0, -10.0 );
|
||||
const auto px1 = std::min( pr1, double( w + 10 ) );
|
||||
draw->AddRectFilled( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y ), color, 2.f );
|
||||
draw->AddRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y ), GetZoneHighlight( ev ), 2.f, -1, GetZoneThickness( ev ) );
|
||||
draw->AddRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y ), GetZoneHighlight( ev, migration ), 2.f, -1, GetZoneThickness( ev ) );
|
||||
if( dsz * dmul >= MinVisSize )
|
||||
{
|
||||
draw->AddRectFilled( wpos + ImVec2( pr0, offset ), wpos + ImVec2( std::min( pr0+dsz*dmul, pr1 ), offset + tsz.y ), 0x882222DD, 2.f );
|
||||
@ -1374,12 +1397,6 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
|
||||
}
|
||||
}
|
||||
|
||||
if( !ev.child.empty() )
|
||||
{
|
||||
const auto d = DrawZoneLevel( ev.child, hover, pxns, wpos, _offset, depth+1 );
|
||||
if( d > maxdepth ) maxdepth = d;
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
@ -1508,7 +1525,7 @@ uint32_t View::GetZoneColor( const QueueSourceLocation& srcloc )
|
||||
return srcloc.color != 0 ? ( srcloc.color | 0xFF000000 ) : 0xFFCC5555;
|
||||
}
|
||||
|
||||
uint32_t View::GetZoneHighlight( const Event& ev )
|
||||
uint32_t View::GetZoneHighlight( const Event& ev, bool migration )
|
||||
{
|
||||
if( m_zoneInfoWindow == &ev )
|
||||
{
|
||||
@ -1518,6 +1535,10 @@ uint32_t View::GetZoneHighlight( const Event& ev )
|
||||
{
|
||||
return 0xFF4444FF;
|
||||
}
|
||||
else if( migration )
|
||||
{
|
||||
return 0xFFDD22DD;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto color = GetZoneColor( ev );
|
||||
|
||||
@ -93,7 +93,7 @@ private:
|
||||
|
||||
uint32_t GetZoneColor( const Event& ev );
|
||||
uint32_t GetZoneColor( const QueueSourceLocation& srcloc );
|
||||
uint32_t GetZoneHighlight( const Event& ev );
|
||||
uint32_t GetZoneHighlight( const Event& ev, bool migration );
|
||||
float GetZoneThickness( const Event& ev );
|
||||
|
||||
void ZoomToZone( const Event& ev );
|
||||
@ -154,6 +154,8 @@ private:
|
||||
uint64_t m_resolution;
|
||||
double m_timerMul;
|
||||
|
||||
int8_t m_lastCpu;
|
||||
|
||||
const Event* m_zoneInfoWindow;
|
||||
const Event* m_zoneHighlight;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user