From 4c1b06034b487fdc3391f2ca52932e72c92b862d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 23 Mar 2024 13:54:39 +0100 Subject: [PATCH] Display program run time percentage in lines selection summary. --- profiler/src/profiler/TracySourceView.cpp | 24 +++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/profiler/src/profiler/TracySourceView.cpp b/profiler/src/profiler/TracySourceView.cpp index 4f0cfb9a..08b89669 100644 --- a/profiler/src/profiler/TracySourceView.cpp +++ b/profiler/src/profiler/TracySourceView.cpp @@ -2256,13 +2256,21 @@ void SourceView::RenderSymbolSourceView( const AddrStatData& as, Worker& worker, ImGui::SameLine(); if( m_cost == CostType::SampleCount ) { + int64_t time; if( m_childCalls ) { - TextFocused( "Time:", TimeToString( ( count.local + count.ext ) * worker.GetSamplingPeriod() ) ); + time = ( count.local + count.ext ) * worker.GetSamplingPeriod(); } else { - TextFocused( "Time:", TimeToString( count.local * worker.GetSamplingPeriod() ) ); + time = count.local * worker.GetSamplingPeriod(); + } + TextFocused( "Time:", TimeToString( time ) ); + const auto timePct = 100.f * time / worker.GetLastTime(); + if( timePct >= 0.01f ) + { + ImGui::SameLine(); + ImGui::TextDisabled( "(%.2f%% run time)", timePct ); } ImGui::SameLine(); ImGui::Spacing(); @@ -3097,13 +3105,21 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker ImGui::SameLine(); if( m_cost == CostType::SampleCount ) { + int64_t time; if( m_childCalls ) { - TextFocused( "Time:", TimeToString( ( count.local + count.ext ) * worker.GetSamplingPeriod() ) ); + time = ( count.local + count.ext ) * worker.GetSamplingPeriod(); } else { - TextFocused( "Time:", TimeToString( count.local * worker.GetSamplingPeriod() ) ); + time = count.local * worker.GetSamplingPeriod(); + } + TextFocused( "Time:", TimeToString( time ) ); + const auto timePct = 100.f * time / worker.GetLastTime(); + if( timePct >= 0.01f ) + { + ImGui::SameLine(); + ImGui::TextDisabled( "(%.2f%% run time)", timePct ); } ImGui::SameLine(); ImGui::Spacing();