mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Add per-thread ghost zones switch.
This commit is contained in:
parent
6daa429b69
commit
77d30adee9
@ -2713,122 +2713,153 @@ void View::DrawZones()
|
|||||||
}
|
}
|
||||||
DrawTextContrast( draw, wpos + ImVec2( ty, oldOffset ), labelColor, txt );
|
DrawTextContrast( draw, wpos + ImVec2( ty, oldOffset ), labelColor, txt );
|
||||||
|
|
||||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( 0, oldOffset ), wpos + ImVec2( ty + txtsz.x, oldOffset + ty ) ) )
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
const bool hasGhostZones = showFull && m_worker.AreGhostZonesReady() && !v->ghostZones.empty();
|
||||||
|
float ghostSz;
|
||||||
|
if( hasGhostZones )
|
||||||
{
|
{
|
||||||
m_drawThreadMigrations = v->id;
|
auto& vis = Vis( v );
|
||||||
m_drawThreadHighlight = v->id;
|
const auto color = vis.ghost ? 0xFFAA9999 : 0x88AA7777;
|
||||||
ImGui::BeginTooltip();
|
|
||||||
SmallColorBox( GetThreadColor( v->id, 0 ) );
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::TextUnformatted( m_worker.GetThreadName( v->id ) );
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::TextDisabled( "(%s)", RealToString( v->id ) );
|
|
||||||
if( crash.thread == v->id )
|
|
||||||
{
|
|
||||||
ImGui::SameLine();
|
|
||||||
#ifdef TRACY_EXTENDED_FONT
|
#ifdef TRACY_EXTENDED_FONT
|
||||||
TextColoredUnformatted( ImVec4( 1.f, 0.2f, 0.2f, 1.f ), ICON_FA_SKULL " Crashed" );
|
draw->AddText( wpos + ImVec2( 1.5f * ty + txtsz.x, oldOffset ), color, ICON_FA_GHOST );
|
||||||
|
ghostSz = ImGui::CalcTextSize( ICON_FA_GHOST ).x;
|
||||||
#else
|
#else
|
||||||
TextColoredUnformatted( ImVec4( 1.f, 0.2f, 0.2f, 1.f ), "Crashed" );
|
draw->AddText( draw, wpos + ImVec2( 1.5f * ty + txtsz.x, oldOffset ), color, "ghost" );
|
||||||
|
ghostSz = ImGui::CalcTextSize( "ghost" ).x;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
const auto ctx = m_worker.GetContextSwitchData( v->id );
|
if( hover )
|
||||||
|
{
|
||||||
ImGui::Separator();
|
#ifndef TRACY_NO_STATISTICS
|
||||||
int64_t first = std::numeric_limits<int64_t>::max();
|
if( hasGhostZones && ImGui::IsMouseHoveringRect( wpos + ImVec2( 1.5f * ty + txtsz.x, oldOffset ), wpos + ImVec2( 1.5f * ty + txtsz.x + ghostSz, oldOffset + ty ) ) )
|
||||||
int64_t last = -1;
|
|
||||||
if( ctx && !ctx->v.empty() )
|
|
||||||
{
|
{
|
||||||
const auto& back = ctx->v.back();
|
if( ImGui::IsMouseClicked( 0 ) )
|
||||||
first = ctx->v.begin()->Start();
|
|
||||||
last = back.IsEndValid() ? back.End() : back.Start();
|
|
||||||
}
|
|
||||||
if( !v->timeline.empty() )
|
|
||||||
{
|
|
||||||
if( v->timeline.is_magic() )
|
|
||||||
{
|
{
|
||||||
auto& tl = *((Vector<ZoneEvent>*)&v->timeline);
|
auto& vis = Vis( v );
|
||||||
first = std::min( first, tl.front().Start() );
|
vis.ghost = !vis.ghost;
|
||||||
last = std::max( last, m_worker.GetZoneEnd( tl.back() ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
first = std::min( first, v->timeline.front()->Start() );
|
|
||||||
last = std::max( last, m_worker.GetZoneEnd( *v->timeline.back() ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( !v->messages.empty() )
|
else
|
||||||
|
#endif
|
||||||
|
if( ImGui::IsMouseHoveringRect( wpos + ImVec2( 0, oldOffset ), wpos + ImVec2( ty + txtsz.x, oldOffset + ty ) ) )
|
||||||
{
|
{
|
||||||
first = std::min( first, v->messages.front()->time );
|
m_drawThreadMigrations = v->id;
|
||||||
last = std::max( last, v->messages.back()->time );
|
m_drawThreadHighlight = v->id;
|
||||||
}
|
ImGui::BeginTooltip();
|
||||||
size_t lockCnt = 0;
|
SmallColorBox( GetThreadColor( v->id, 0 ) );
|
||||||
for( const auto& lock : m_worker.GetLockMap() )
|
|
||||||
{
|
|
||||||
const auto& lockmap = *lock.second;
|
|
||||||
if( !lockmap.valid ) continue;
|
|
||||||
auto it = lockmap.threadMap.find( v->id );
|
|
||||||
if( it == lockmap.threadMap.end() ) continue;
|
|
||||||
lockCnt++;
|
|
||||||
const auto thread = it->second;
|
|
||||||
auto lptr = lockmap.timeline.data();
|
|
||||||
auto eptr = lptr + lockmap.timeline.size() - 1;
|
|
||||||
while( lptr->ptr->thread != thread ) lptr++;
|
|
||||||
if( lptr->ptr->Time() < first ) first = lptr->ptr->Time();
|
|
||||||
while( eptr->ptr->thread != thread ) eptr--;
|
|
||||||
if( eptr->ptr->Time() > last ) last = eptr->ptr->Time();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( last >= 0 )
|
|
||||||
{
|
|
||||||
const auto lifetime = last - first;
|
|
||||||
const auto traceLen = m_worker.GetLastTime();
|
|
||||||
|
|
||||||
TextFocused( "Appeared at", TimeToString( first ) );
|
|
||||||
TextFocused( "Last event at", TimeToString( last ) );
|
|
||||||
TextFocused( "Lifetime:", TimeToString( lifetime ) );
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
char buf[64];
|
ImGui::TextUnformatted( m_worker.GetThreadName( v->id ) );
|
||||||
PrintStringPercent( buf, lifetime / double( traceLen ) * 100 );
|
ImGui::SameLine();
|
||||||
TextDisabledUnformatted( buf );
|
ImGui::TextDisabled( "(%s)", RealToString( v->id ) );
|
||||||
|
if( crash.thread == v->id )
|
||||||
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
#ifdef TRACY_EXTENDED_FONT
|
||||||
|
TextColoredUnformatted( ImVec4( 1.f, 0.2f, 0.2f, 1.f ), ICON_FA_SKULL " Crashed" );
|
||||||
|
#else
|
||||||
|
TextColoredUnformatted( ImVec4( 1.f, 0.2f, 0.2f, 1.f ), "Crashed" );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto ctx = m_worker.GetContextSwitchData( v->id );
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
int64_t first = std::numeric_limits<int64_t>::max();
|
||||||
|
int64_t last = -1;
|
||||||
|
if( ctx && !ctx->v.empty() )
|
||||||
|
{
|
||||||
|
const auto& back = ctx->v.back();
|
||||||
|
first = ctx->v.begin()->Start();
|
||||||
|
last = back.IsEndValid() ? back.End() : back.Start();
|
||||||
|
}
|
||||||
|
if( !v->timeline.empty() )
|
||||||
|
{
|
||||||
|
if( v->timeline.is_magic() )
|
||||||
|
{
|
||||||
|
auto& tl = *((Vector<ZoneEvent>*)&v->timeline);
|
||||||
|
first = std::min( first, tl.front().Start() );
|
||||||
|
last = std::max( last, m_worker.GetZoneEnd( tl.back() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
first = std::min( first, v->timeline.front()->Start() );
|
||||||
|
last = std::max( last, m_worker.GetZoneEnd( *v->timeline.back() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( !v->messages.empty() )
|
||||||
|
{
|
||||||
|
first = std::min( first, v->messages.front()->time );
|
||||||
|
last = std::max( last, v->messages.back()->time );
|
||||||
|
}
|
||||||
|
size_t lockCnt = 0;
|
||||||
|
for( const auto& lock : m_worker.GetLockMap() )
|
||||||
|
{
|
||||||
|
const auto& lockmap = *lock.second;
|
||||||
|
if( !lockmap.valid ) continue;
|
||||||
|
auto it = lockmap.threadMap.find( v->id );
|
||||||
|
if( it == lockmap.threadMap.end() ) continue;
|
||||||
|
lockCnt++;
|
||||||
|
const auto thread = it->second;
|
||||||
|
auto lptr = lockmap.timeline.data();
|
||||||
|
auto eptr = lptr + lockmap.timeline.size() - 1;
|
||||||
|
while( lptr->ptr->thread != thread ) lptr++;
|
||||||
|
if( lptr->ptr->Time() < first ) first = lptr->ptr->Time();
|
||||||
|
while( eptr->ptr->thread != thread ) eptr--;
|
||||||
|
if( eptr->ptr->Time() > last ) last = eptr->ptr->Time();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( last >= 0 )
|
||||||
|
{
|
||||||
|
const auto lifetime = last - first;
|
||||||
|
const auto traceLen = m_worker.GetLastTime();
|
||||||
|
|
||||||
|
TextFocused( "Appeared at", TimeToString( first ) );
|
||||||
|
TextFocused( "Last event at", TimeToString( last ) );
|
||||||
|
TextFocused( "Lifetime:", TimeToString( lifetime ) );
|
||||||
|
ImGui::SameLine();
|
||||||
|
char buf[64];
|
||||||
|
PrintStringPercent( buf, lifetime / double( traceLen ) * 100 );
|
||||||
|
TextDisabledUnformatted( buf );
|
||||||
|
|
||||||
|
if( ctx )
|
||||||
|
{
|
||||||
|
TextFocused( "Time in running state:", TimeToString( ctx->runningTime ) );
|
||||||
|
ImGui::SameLine();
|
||||||
|
PrintStringPercent( buf, ctx->runningTime / double( lifetime ) * 100 );
|
||||||
|
TextDisabledUnformatted( buf );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
if( !v->timeline.empty() )
|
||||||
|
{
|
||||||
|
TextFocused( "Zone count:", RealToString( v->count ) );
|
||||||
|
TextFocused( "Top-level zones:", RealToString( v->timeline.size() ) );
|
||||||
|
}
|
||||||
|
if( !v->messages.empty() )
|
||||||
|
{
|
||||||
|
TextFocused( "Messages:", RealToString( v->messages.size() ) );
|
||||||
|
}
|
||||||
|
if( lockCnt != 0 )
|
||||||
|
{
|
||||||
|
TextFocused( "Locks:", RealToString( lockCnt ) );
|
||||||
|
}
|
||||||
if( ctx )
|
if( ctx )
|
||||||
{
|
{
|
||||||
TextFocused( "Time in running state:", TimeToString( ctx->runningTime ) );
|
TextFocused( "Running state regions:", RealToString( ctx->v.size() ) );
|
||||||
ImGui::SameLine();
|
|
||||||
PrintStringPercent( buf, ctx->runningTime / double( lifetime ) * 100 );
|
|
||||||
TextDisabledUnformatted( buf );
|
|
||||||
}
|
}
|
||||||
}
|
ImGui::EndTooltip();
|
||||||
|
|
||||||
ImGui::Separator();
|
if( ImGui::IsMouseClicked( 0 ) )
|
||||||
if( !v->timeline.empty() )
|
{
|
||||||
{
|
Vis( v ).showFull = !showFull;
|
||||||
TextFocused( "Zone count:", RealToString( v->count ) );
|
}
|
||||||
TextFocused( "Top-level zones:", RealToString( v->timeline.size() ) );
|
if( last >= 0 && ImGui::IsMouseClicked( 2 ) )
|
||||||
}
|
{
|
||||||
if( !v->messages.empty() )
|
ZoomToRange( first, last );
|
||||||
{
|
}
|
||||||
TextFocused( "Messages:", RealToString( v->messages.size() ) );
|
|
||||||
}
|
|
||||||
if( lockCnt != 0 )
|
|
||||||
{
|
|
||||||
TextFocused( "Locks:", RealToString( lockCnt ) );
|
|
||||||
}
|
|
||||||
if( ctx )
|
|
||||||
{
|
|
||||||
TextFocused( "Running state regions:", RealToString( ctx->v.size() ) );
|
|
||||||
}
|
|
||||||
ImGui::EndTooltip();
|
|
||||||
|
|
||||||
if( ImGui::IsMouseClicked( 0 ) )
|
|
||||||
{
|
|
||||||
Vis( v ).showFull = !showFull;
|
|
||||||
}
|
|
||||||
if( last >= 0 && ImGui::IsMouseClicked( 2 ) )
|
|
||||||
{
|
|
||||||
ZoomToRange( first, last );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ public:
|
|||||||
{
|
{
|
||||||
bool visible = true;
|
bool visible = true;
|
||||||
bool showFull = true;
|
bool showFull = true;
|
||||||
|
bool ghost = false;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user