From d151aff237541c77ca2ce7deb77ce937fbe36b69 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 7 Aug 2020 19:26:19 +0200 Subject: [PATCH] Allow time limiting sampled call stacks statistics. --- server/TracyView.cpp | 97 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 5 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 009ff0db..96fa1518 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -12042,7 +12042,32 @@ void View::DrawStatistics() } else { - data.push_back_no_space_check( SymList { v.first, it->second.incl, it->second.excl } ); + if( m_statRange.active ) + { + auto samples = m_worker.GetSamplesForSymbol( v.first ); + if( samples ) + { + auto it = std::lower_bound( samples->begin(), samples->end(), m_statRange.min, [] ( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs; } ); + if( it != samples->end() ) + { + auto end = std::lower_bound( it, samples->end(), m_statRange.max, [] ( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs; } ); + const auto count = uint32_t( end - it ); + data.push_back_no_space_check( SymList { v.first, 0, count } ); + } + else + { + data.push_back_no_space_check( SymList { v.first, 0, 0 } ); + } + } + else + { + data.push_back_no_space_check( SymList { v.first, 0, 0 } ); + } + } + else + { + data.push_back_no_space_check( SymList { v.first, it->second.incl, it->second.excl } ); + } } } } @@ -12058,7 +12083,32 @@ void View::DrawStatistics() } else { - data.push_back_no_space_check( SymList { v.first, it->second.incl, it->second.excl } ); + if( m_statRange.active ) + { + auto samples = m_worker.GetSamplesForSymbol( v.first ); + if( samples ) + { + auto it = std::lower_bound( samples->begin(), samples->end(), m_statRange.min, [] ( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs; } ); + if( it != samples->end() ) + { + auto end = std::lower_bound( it, samples->end(), m_statRange.max, [] ( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs; } ); + const auto count = uint32_t( end - it ); + data.push_back_no_space_check( SymList { v.first, 0, count } ); + } + else + { + data.push_back_no_space_check( SymList { v.first, 0, 0 } ); + } + } + else + { + data.push_back_no_space_check( SymList { v.first, 0, 0 } ); + } + } + else + { + data.push_back_no_space_check( SymList { v.first, it->second.incl, it->second.excl } ); + } } } } @@ -12090,16 +12140,53 @@ void View::DrawStatistics() } if( pass ) { - data.push_back_no_space_check( SymList { v.first, v.second.incl, v.second.excl } ); + if( m_statRange.active ) + { + auto samples = m_worker.GetSamplesForSymbol( v.first ); + if( samples ) + { + auto it = std::lower_bound( samples->begin(), samples->end(), m_statRange.min, [] ( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs; } ); + if( it != samples->end() ) + { + auto end = std::lower_bound( it, samples->end(), m_statRange.max, [] ( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs; } ); + const auto count = uint32_t( end - it ); + data.push_back_no_space_check( SymList { v.first, 0, count } ); + } + } + } + else + { + data.push_back_no_space_check( SymList { v.first, v.second.incl, v.second.excl } ); + } } } } } else { - for( auto& v : symStat ) + if( m_statRange.active ) { - data.push_back_no_space_check( SymList { v.first, v.second.incl, v.second.excl } ); + for( auto& v : symStat ) + { + auto samples = m_worker.GetSamplesForSymbol( v.first ); + if( samples ) + { + auto it = std::lower_bound( samples->begin(), samples->end(), m_statRange.min, [] ( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs; } ); + if( it != samples->end() ) + { + auto end = std::lower_bound( it, samples->end(), m_statRange.max, [] ( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs; } ); + const auto count = uint32_t( end - it ); + data.push_back_no_space_check( SymList { v.first, 0, count } ); + } + } + } + } + else + { + for( auto& v : symStat ) + { + data.push_back_no_space_check( SymList { v.first, v.second.incl, v.second.excl } ); + } } } }