Don't divide by zero in zero-length zones.

This commit is contained in:
Bartosz Taudul 2019-06-22 22:42:57 +02:00
parent 1d4117f515
commit c48cd10f35

View File

@ -4256,8 +4256,11 @@ void View::DrawZoneInfoWindow()
ImGui::TextDisabled( "(%.2f%% of average time)", float( ztime ) / zoneData.total * zoneData.zones.size() * 100 ); ImGui::TextDisabled( "(%.2f%% of average time)", float( ztime ) / zoneData.total * zoneData.zones.size() * 100 );
#endif #endif
TextFocused( "Self time:", TimeToString( selftime ) ); TextFocused( "Self time:", TimeToString( selftime ) );
ImGui::SameLine(); if( ztime != 0 )
ImGui::TextDisabled( "(%.2f%%)", 100.f * selftime / ztime ); {
ImGui::SameLine();
ImGui::TextDisabled( "(%.2f%%)", 100.f * selftime / ztime );
}
auto& mem = m_worker.GetMemData(); auto& mem = m_worker.GetMemData();
if( !mem.data.empty() ) if( !mem.data.empty() )
@ -4825,8 +4828,11 @@ void View::DrawGpuInfoWindow()
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 ) );
ImGui::SameLine(); if( ztime != 0 )
ImGui::TextDisabled( "(%.2f%%)", 100.f * selftime / ztime ); {
ImGui::SameLine();
ImGui::TextDisabled( "(%.2f%%)", 100.f * selftime / ztime );
}
TextFocused( "CPU command setup time:", TimeToString( ev.cpuEnd - ev.cpuStart ) ); TextFocused( "CPU command setup time:", TimeToString( ev.cpuEnd - ev.cpuStart ) );
auto ctx = GetZoneCtx( ev ); auto ctx = GetZoneCtx( ev );
if( !ctx ) if( !ctx )
@ -10390,8 +10396,11 @@ void View::ZoneTooltip( const ZoneEvent& ev )
ImGui::TextDisabled( "(%.2f%% of average time)", float( ztime ) / zoneData.total * zoneData.zones.size() * 100 ); ImGui::TextDisabled( "(%.2f%% of average time)", float( ztime ) / zoneData.total * zoneData.zones.size() * 100 );
#endif #endif
TextFocused( "Self time:", TimeToString( selftime ) ); TextFocused( "Self time:", TimeToString( selftime ) );
ImGui::SameLine(); if( ztime != 0 )
ImGui::TextDisabled( "(%.2f%%)", 100.f * selftime / ztime ); {
ImGui::SameLine();
ImGui::TextDisabled( "(%.2f%%)", 100.f * selftime / ztime );
}
if( ev.cpu_start >= 0 ) if( ev.cpu_start >= 0 )
{ {
TextDisabledUnformatted( "CPU:" ); TextDisabledUnformatted( "CPU:" );
@ -10432,8 +10441,11 @@ void View::ZoneTooltip( const GpuEvent& ev )
ImGui::Separator(); ImGui::Separator();
TextFocused( "GPU execution time:", TimeToString( ztime ) ); TextFocused( "GPU execution time:", TimeToString( ztime ) );
TextFocused( "GPU self time:", TimeToString( selftime ) ); TextFocused( "GPU self time:", TimeToString( selftime ) );
ImGui::SameLine(); if( ztime != 0 )
ImGui::TextDisabled( "(%.2f%%)", 100.f * selftime / ztime ); {
ImGui::SameLine();
ImGui::TextDisabled( "(%.2f%%)", 100.f * selftime / ztime );
}
TextFocused( "CPU command setup time:", TimeToString( ev.cpuEnd - ev.cpuStart ) ); TextFocused( "CPU command setup time:", TimeToString( ev.cpuEnd - ev.cpuStart ) );
auto ctx = GetZoneCtx( ev ); auto ctx = GetZoneCtx( ev );
if( !ctx ) if( !ctx )