diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 86c78f94..d2556902 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -244,7 +244,7 @@ Worker::Worker( const char* addr, int port ) #ifndef TRACY_NO_STATISTICS m_data.sourceLocationZonesReady = true; - m_data.callstackSamplesReady = false; // FIXME implement live data update + m_data.callstackSamplesReady = true; m_data.ctxUsageReady = true; #endif @@ -1737,44 +1737,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) } } } - for( auto& v : counts ) - { - const auto count = v.second; - const auto& cs = GetCallstack( v.first ); - const auto cssz = cs.size(); - - const auto fexcl = GetCallstackFrame( cs[0] ); - if( fexcl ) - { - const auto fsz = fexcl->size; - const auto& frame0 = fexcl->data[0]; - auto sym = m_data.symbolStats.find( frame0.symAddr ); - if( sym == m_data.symbolStats.end() ) sym = m_data.symbolStats.emplace( frame0.symAddr, SymbolStats {} ).first; - sym->second.excl += count; - for( uint8_t f=1; fdata[f]; - sym = m_data.symbolStats.find( frame.symAddr ); - if( sym == m_data.symbolStats.end() ) sym = m_data.symbolStats.emplace( frame.symAddr, SymbolStats {} ).first; - sym->second.incl += count; - } - } - for( uint8_t c=1; csize; - for( uint8_t f=0; fdata[f]; - auto sym = m_data.symbolStats.find( frame.symAddr ); - if( sym == m_data.symbolStats.end() ) sym = m_data.symbolStats.emplace( frame.symAddr, SymbolStats {} ).first; - sym->second.incl += count; - } - } - } - } + for( auto& v : counts ) UpdateSampleStatistics( v.first, v.second ); } std::lock_guard lock( m_data.lock ); @@ -4778,6 +4741,10 @@ void Worker::ProcessCallstackSample( const QueueCallstackSample& ev ) } } } + +#ifndef TRACY_NO_STATISTICS + UpdateSampleStatistics( m_pendingCallstackId, 1 ); +#endif } void Worker::ProcessCallstackFrameSize( const QueueCallstackFrameSize& ev ) @@ -5278,6 +5245,44 @@ void Worker::ReconstructContextSwitchUsage() std::lock_guard lock( m_data.lock ); m_data.ctxUsageReady = true; } + +void Worker::UpdateSampleStatistics( uint32_t callstack, uint32_t count ) +{ + const auto& cs = GetCallstack( callstack ); + const auto cssz = cs.size(); + + const auto fexcl = GetCallstackFrame( cs[0] ); + if( fexcl ) + { + const auto fsz = fexcl->size; + const auto& frame0 = fexcl->data[0]; + auto sym = m_data.symbolStats.find( frame0.symAddr ); + if( sym == m_data.symbolStats.end() ) sym = m_data.symbolStats.emplace( frame0.symAddr, SymbolStats {} ).first; + sym->second.excl += count; + for( uint8_t f=1; fdata[f]; + sym = m_data.symbolStats.find( frame.symAddr ); + if( sym == m_data.symbolStats.end() ) sym = m_data.symbolStats.emplace( frame.symAddr, SymbolStats {} ).first; + sym->second.incl += count; + } + } + for( uint8_t c=1; csize; + for( uint8_t f=0; fdata[f]; + auto sym = m_data.symbolStats.find( frame.symAddr ); + if( sym == m_data.symbolStats.end() ) sym = m_data.symbolStats.emplace( frame.symAddr, SymbolStats {} ).first; + sym->second.incl += count; + } + } + } +} #endif int64_t Worker::ReadTimeline( FileRead& f, ZoneEvent* zone, int64_t refTime, int32_t& childIdx ) diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index d04631e8..1001b053 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -638,6 +638,7 @@ private: #ifndef TRACY_NO_STATISTICS void ReconstructContextSwitchUsage(); + void UpdateSampleStatistics( uint32_t callstack, uint32_t count ); #endif tracy_force_inline int64_t ReadTimeline( FileRead& f, ZoneEvent* zone, int64_t refTime, int32_t& childIdx );