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

View File

@ -4437,7 +4437,7 @@ void View::DrawZoneInfoWindow()
const auto end = m_worker.GetZoneEnd( ev ); const auto end = m_worker.GetZoneEnd( ev );
const auto ztime = end - ev.start; 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( "Time from start of program:", TimeToString( ev.start - m_worker.GetTimeBegin() ) );
TextFocused( "Execution time:", TimeToString( ztime ) ); TextFocused( "Execution time:", TimeToString( ztime ) );
if( ImGui::IsItemHovered() ) if( ImGui::IsItemHovered() )
@ -5009,7 +5009,7 @@ void View::DrawGpuInfoWindow()
const auto end = m_worker.GetZoneEnd( ev ); const auto end = m_worker.GetZoneEnd( ev );
const auto ztime = end - ev.gpuStart; 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( "Time from start of program:", TimeToString( ev.gpuStart - m_worker.GetTimeBegin() ) );
TextFocused( "GPU execution time:", TimeToString( ztime ) ); TextFocused( "GPU execution time:", TimeToString( ztime ) );
TextFocused( "GPU self time:", TimeToString( selftime ) ); TextFocused( "GPU self time:", TimeToString( selftime ) );
@ -9850,7 +9850,7 @@ void View::ZoneTooltip( const ZoneEvent& ev )
auto& srcloc = m_worker.GetSourceLocation( ev.srcloc ); auto& srcloc = m_worker.GetSourceLocation( ev.srcloc );
const auto end = m_worker.GetZoneEnd( ev ); const auto end = m_worker.GetZoneEnd( ev );
const auto ztime = end - ev.start; const auto ztime = end - ev.start;
const auto selftime = ztime - GetZoneChildTime( ev ); const auto selftime = GetZoneSelfTime( ev );
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if( ev.name.active ) if( ev.name.active )
@ -9899,7 +9899,7 @@ void View::ZoneTooltip( const GpuEvent& ev )
const auto& srcloc = m_worker.GetSourceLocation( ev.srcloc ); const auto& srcloc = m_worker.GetSourceLocation( ev.srcloc );
const auto end = m_worker.GetZoneEnd( ev ); const auto end = m_worker.GetZoneEnd( ev );
const auto ztime = end - ev.gpuStart; const auto ztime = end - ev.gpuStart;
const auto selftime = ztime - GetZoneChildTime( ev ); const auto selftime = GetZoneSelfTime( ev );
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::TextUnformatted( m_worker.GetString( srcloc.name ) ); ImGui::TextUnformatted( m_worker.GetString( srcloc.name ) );
@ -10262,4 +10262,22 @@ int64_t View::GetZoneChildTimeFast( const ZoneEvent& zone )
return time; 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;
}
} }

View File

@ -188,6 +188,8 @@ private:
int64_t GetZoneChildTime( const ZoneEvent& zone ); int64_t GetZoneChildTime( const ZoneEvent& zone );
int64_t GetZoneChildTime( const GpuEvent& zone ); int64_t GetZoneChildTime( const GpuEvent& zone );
int64_t GetZoneChildTimeFast( const ZoneEvent& zone ); int64_t GetZoneChildTimeFast( const ZoneEvent& zone );
int64_t GetZoneSelfTime( const ZoneEvent& zone );
int64_t GetZoneSelfTime( const GpuEvent& zone );
flat_hash_map<const void*, VisData, nohash<const void*>> m_visData; flat_hash_map<const void*, VisData, nohash<const void*>> m_visData;
flat_hash_map<uint64_t, bool, nohash<uint64_t>> m_visibleMsgThread; flat_hash_map<uint64_t, bool, nohash<uint64_t>> m_visibleMsgThread;
@ -472,6 +474,11 @@ private:
std::unique_ptr<int64_t[]> bins; std::unique_ptr<int64_t[]> bins;
bool drawAvgMed = true; bool drawAvgMed = true;
} m_frameSortData; } m_frameSortData;
struct {
std::pair<const ZoneEvent*, int64_t> zoneSelfTime = { nullptr, 0 };
std::pair<const GpuEvent*, int64_t> gpuSelfTime = { nullptr, 0 };
} m_cache;
}; };
} }