From 34fa99c7eed9d65b5ab9783666a475cfdcae4d4a Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 11 Aug 2020 15:50:54 +0200 Subject: [PATCH] Restrict sample statistics percentages to time range limit. --- server/TracyView.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 70c366e9..1cae27ad 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -12274,6 +12274,18 @@ void View::DrawStatistics() ImGui::NextColumn(); ImGui::Separator(); + double revSampleCount100; + if( m_statRange.active ) + { + const auto st = m_statRange.max - m_statRange.min; + const auto cnt = st / m_worker.GetSamplingPeriod(); + revSampleCount100 = 100. / cnt; + } + else + { + revSampleCount100 = 100. / m_worker.GetCallstackSampleCount(); + } + const bool showAll = m_showAllSymbols; const auto period = m_worker.GetSamplingPeriod(); int idx = 0; @@ -12449,16 +12461,18 @@ void View::DrawStatistics() ImGui::NextColumn(); if( cnt > 0 ) { + char buf[64]; if( m_statSampleTime ) { - ImGui::TextUnformatted( TimeToString( cnt * period ) ); + const auto t = cnt * period; + ImGui::TextUnformatted( TimeToString( t ) ); + PrintStringPercent( buf, 100. * t / timeRange ); } else { ImGui::TextUnformatted( RealToString( cnt ) ); + PrintStringPercent( buf, cnt * revSampleCount100 ); } - char buf[64]; - PrintStringPercent( buf, 100. * cnt / m_worker.GetCallstackSampleCount() ); ImGui::SameLine(); TextDisabledUnformatted( buf ); } @@ -12613,16 +12627,18 @@ void View::DrawStatistics() ImGui::NextColumn(); if( cnt > 0 ) { + char buf[64]; if( m_statSampleTime ) { - ImGui::TextUnformatted( TimeToString( cnt * period ) ); + const auto t = cnt * period; + ImGui::TextUnformatted( TimeToString( t ) ); + PrintStringPercent( buf, 100. * t / timeRange ); } else { ImGui::TextUnformatted( RealToString( cnt ) ); + PrintStringPercent( buf, cnt * revSampleCount100 ); } - char buf[64]; - PrintStringPercent( buf, 100. * cnt / m_worker.GetCallstackSampleCount() ); ImGui::SameLine(); TextDisabledUnformatted( buf ); }