From 8187519775966d4a4dcae29d435b554d9a6a517c Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 20 Dec 2023 17:06:28 +0100 Subject: [PATCH] Add threads count to SrcLocZonesSlim. --- server/TracyView.hpp | 1 + server/TracyView_Statistics.cpp | 37 ++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 6f2c6292..ff1c234a 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -89,6 +89,7 @@ class View size_t sourceCount; size_t count; int64_t total; + uint16_t threadNum; }; public: diff --git a/server/TracyView_Statistics.cpp b/server/TracyView_Statistics.cpp index 625ec220..737b40f6 100644 --- a/server/TracyView_Statistics.cpp +++ b/server/TracyView_Statistics.cpp @@ -11,6 +11,7 @@ extern double s_time; struct SrcLocZonesSlim { int16_t srcloc; + uint16_t numThreads; size_t numZones; int64_t total; }; @@ -118,11 +119,12 @@ void View::DrawStatistics() if( cit->second.count != 0 ) { slzcnt++; - srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cit->second.count, cit->second.total } ); + srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cit->second.threadNum, cit->second.count, cit->second.total } ); } } else { + unordered_flat_set threads; size_t cnt = 0; int64_t total = 0; for( auto& v : it->second.zones ) @@ -137,20 +139,23 @@ void View::DrawStatistics() { total += zt - GetZoneChildTimeFast( z ); cnt++; + threads.emplace( v.Thread() ); } else if( m_statAccumulationMode == AccumulationMode::AllChildren || !IsZoneReentry( z ) ) { total += zt; cnt++; + threads.emplace( v.Thread() ); } } } + const auto threadNum = (uint16_t)threads.size(); if( cnt != 0 ) { slzcnt++; - srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cnt, total } ); + srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, threadNum, cnt, total } ); } - m_statCache[it->first] = StatisticsCache { RangeSlim { m_statRange.min, m_statRange.max, m_statRange.active }, m_statAccumulationMode, it->second.zones.size(), cnt, total }; + m_statCache[it->first] = StatisticsCache { RangeSlim { m_statRange.min, m_statRange.max, m_statRange.active }, m_statAccumulationMode, it->second.zones.size(), cnt, total, threadNum }; } } else @@ -165,11 +170,12 @@ void View::DrawStatistics() { if( cit->second.count != 0 ) { - srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cit->second.count, cit->second.total } ); + srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cit->second.threadNum, cit->second.count, cit->second.total } ); } } else { + unordered_flat_set threads; size_t cnt = 0; int64_t total = 0; for( auto& v : it->second.zones ) @@ -184,19 +190,22 @@ void View::DrawStatistics() { total += zt - GetZoneChildTimeFast( z ); cnt++; + threads.emplace( v.Thread() ); } else if( m_statAccumulationMode == AccumulationMode::AllChildren || !IsZoneReentry( z ) ) { total += zt; cnt++; + threads.emplace( v.Thread() ); } } } + const auto threadNum = (uint16_t)threads.size(); if( cnt != 0 ) { - srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cnt, total } ); + srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, threadNum, cnt, total } ); } - m_statCache[it->first] = StatisticsCache { RangeSlim { m_statRange.min, m_statRange.max, m_statRange.active }, m_statAccumulationMode, it->second.zones.size(), cnt, total }; + m_statCache[it->first] = StatisticsCache { RangeSlim { m_statRange.min, m_statRange.max, m_statRange.active }, m_statAccumulationMode, it->second.zones.size(), cnt, total, threadNum }; } } } @@ -229,7 +238,7 @@ void View::DrawStatistics() } if( !filterActive ) { - srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, count, total } ); + srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, (uint16_t)it->second.threadCnt.size(), count, total } ); } else { @@ -237,7 +246,7 @@ void View::DrawStatistics() auto name = m_worker.GetString( sl.name.active ? sl.name : sl.function ); if( m_statisticsFilter.PassFilter( name ) ) { - srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, count, total } ); + srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, (uint16_t)it->second.threadCnt.size(), count, total } ); } } } @@ -331,7 +340,7 @@ void View::DrawStatistics() if( cit->second.count != 0 ) { slzcnt++; - srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cit->second.count, cit->second.total } ); + srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, 0, cit->second.count, cit->second.total } ); } } else @@ -353,7 +362,7 @@ void View::DrawStatistics() if( cnt != 0 ) { slzcnt++; - srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cnt, total } ); + srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, 0, cnt, total } ); } m_gpuStatCache[it->first] = StatisticsCache { RangeSlim { m_statRange.min, m_statRange.max, m_statRange.active }, m_statAccumulationMode, it->second.zones.size(), cnt, total }; } @@ -370,7 +379,7 @@ void View::DrawStatistics() { if( cit->second.count != 0 ) { - srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cit->second.count, cit->second.total } ); + srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, 0, cit->second.count, cit->second.total } ); } } else @@ -391,7 +400,7 @@ void View::DrawStatistics() } if( cnt != 0 ) { - srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cnt, total } ); + srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, 0, cnt, total } ); } m_gpuStatCache[it->first] = StatisticsCache { RangeSlim { m_statRange.min, m_statRange.max, m_statRange.active }, m_statAccumulationMode, it->second.zones.size(), cnt, total }; } @@ -411,7 +420,7 @@ void View::DrawStatistics() int64_t total = it->second.total; if( !filterActive ) { - srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, count, total } ); + srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, 0, count, total } ); } else { @@ -419,7 +428,7 @@ void View::DrawStatistics() auto name = m_worker.GetString( sl.name.active ? sl.name : sl.function ); if( m_statisticsFilter.PassFilter( name ) ) { - srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, count, total } ); + srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, 0, count, total } ); } } }