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

Cache zone self times.

This commit is contained in:
Bartosz Taudul
2019-03-30 00:52:25 +01:00
parent b0ab3c6139
commit 48a07bf4f8
2 changed files with 29 additions and 4 deletions
+22 -4
View File
@@ -4437,7 +4437,7 @@ void View::DrawZoneInfoWindow()
const auto end = m_worker.GetZoneEnd( ev );
const auto ztime = end - ev.start;
const auto selftime = ztime - GetZoneChildTime( ev );
const auto selftime = GetZoneSelfTime( ev );
TextFocused( "Time from start of program:", TimeToString( ev.start - m_worker.GetTimeBegin() ) );
TextFocused( "Execution time:", TimeToString( ztime ) );
if( ImGui::IsItemHovered() )
@@ -5009,7 +5009,7 @@ void View::DrawGpuInfoWindow()
const auto end = m_worker.GetZoneEnd( ev );
const auto ztime = end - ev.gpuStart;
const auto selftime = ztime - GetZoneChildTime( ev );
const auto selftime = GetZoneSelfTime( ev );
TextFocused( "Time from start of program:", TimeToString( ev.gpuStart - m_worker.GetTimeBegin() ) );
TextFocused( "GPU execution time:", TimeToString( ztime ) );
TextFocused( "GPU self time:", TimeToString( selftime ) );
@@ -9850,7 +9850,7 @@ void View::ZoneTooltip( const ZoneEvent& ev )
auto& srcloc = m_worker.GetSourceLocation( ev.srcloc );
const auto end = m_worker.GetZoneEnd( ev );
const auto ztime = end - ev.start;
const auto selftime = ztime - GetZoneChildTime( ev );
const auto selftime = GetZoneSelfTime( ev );
ImGui::BeginTooltip();
if( ev.name.active )
@@ -9899,7 +9899,7 @@ void View::ZoneTooltip( const GpuEvent& ev )
const auto& srcloc = m_worker.GetSourceLocation( ev.srcloc );
const auto end = m_worker.GetZoneEnd( ev );
const auto ztime = end - ev.gpuStart;
const auto selftime = ztime - GetZoneChildTime( ev );
const auto selftime = GetZoneSelfTime( ev );
ImGui::BeginTooltip();
ImGui::TextUnformatted( m_worker.GetString( srcloc.name ) );
@@ -10262,4 +10262,22 @@ int64_t View::GetZoneChildTimeFast( const ZoneEvent& zone )
return time;
}
int64_t View::GetZoneSelfTime( const ZoneEvent& zone )
{
if( m_cache.zoneSelfTime.first == &zone ) return m_cache.zoneSelfTime.second;
const auto ztime = m_worker.GetZoneEnd( zone ) - zone.start;
const auto selftime = ztime - GetZoneChildTime( zone );
if( zone.end >= 0 ) m_cache.zoneSelfTime = std::make_pair( &zone, selftime );
return selftime;
}
int64_t View::GetZoneSelfTime( const GpuEvent& zone )
{
if( m_cache.gpuSelfTime.first == &zone ) return m_cache.gpuSelfTime.second;
const auto ztime = m_worker.GetZoneEnd( zone ) - zone.gpuStart;
const auto selftime = ztime - GetZoneChildTime( zone );
if( zone.gpuEnd >= 0 ) m_cache.gpuSelfTime = std::make_pair( &zone, selftime );
return selftime;
}
}