1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-30 04:43:53 +00:00

Implement range limit for child samples.

This commit is contained in:
Bartosz Taudul 2021-05-19 20:26:50 +02:00
parent 6d8abfe640
commit efc1777051
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -3569,14 +3569,56 @@ void SourceView::GatherIpStats( uint64_t baseAddr, AddrStat& iptotalSrc, AddrSta
void SourceView::GatherAdditionalIpStats( uint64_t baseAddr, AddrStat& iptotalSrc, AddrStat& iptotalAsm, unordered_flat_map<uint64_t, AddrStat>& ipcountSrc, unordered_flat_map<uint64_t, AddrStat>& ipcountAsm, AddrStat& ipmaxSrc, AddrStat& ipmaxAsm, const Worker& worker, bool limitView, const View& view ) void SourceView::GatherAdditionalIpStats( uint64_t baseAddr, AddrStat& iptotalSrc, AddrStat& iptotalAsm, unordered_flat_map<uint64_t, AddrStat>& ipcountSrc, unordered_flat_map<uint64_t, AddrStat>& ipcountAsm, AddrStat& ipmaxSrc, AddrStat& ipmaxAsm, const Worker& worker, bool limitView, const View& view )
{ {
if( !worker.AreSourceLocationZonesReady() ) return; if( !worker.AreSourceLocationZonesReady() ) return;
auto sym = worker.GetSymbolData( baseAddr );
if( !sym ) return;
auto filename = m_source.filename(); auto filename = m_source.filename();
if( limitView ) if( limitView )
{ {
for( uint64_t ip = baseAddr; ip < baseAddr + sym->size.Val(); ip++ )
{
if( ipcountAsm.find( ip ) != ipcountAsm.end() ) continue;
auto cp = worker.GetChildSamples( ip );
if( !cp ) continue;
auto it = std::lower_bound( cp->begin(), cp->end(), view.m_statRange.min, [] ( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs; } );
if( it == cp->end() ) continue;
auto end = std::lower_bound( it, cp->end(), view.m_statRange.max, [] ( const auto& lhs, const auto& rhs ) { return lhs.Val() < rhs; } );
const auto ccnt = uint32_t( end - it );
ipcountAsm.emplace( ip, AddrStat { 0, ccnt } );
iptotalAsm.ext += ccnt;
if( ipmaxAsm.ext < ccnt ) ipmaxAsm.ext = ccnt;
if( filename )
{
auto frame = worker.GetCallstackFrame( worker.PackPointer( ip ) );
if( frame )
{
auto ffn = worker.GetString( frame->data[0].file );
if( strcmp( ffn, filename ) == 0 )
{
const auto line = frame->data[0].line;
if( line != 0 )
{
auto it = ipcountSrc.find( line );
if( it == ipcountSrc.end() )
{
ipcountSrc.emplace( line, AddrStat{ 0, ccnt } );
if( ipmaxSrc.ext < ccnt ) ipmaxSrc.ext = ccnt;
} }
else else
{ {
auto sym = worker.GetSymbolData( baseAddr ); const auto csum = it->second.ext + ccnt;
if( sym ) it->second.ext = csum;
if( ipmaxSrc.ext < csum ) ipmaxSrc.ext = csum;
}
iptotalSrc.ext += ccnt;
}
}
}
}
}
}
else
{ {
for( uint64_t ip = baseAddr; ip < baseAddr + sym->size.Val(); ip++ ) for( uint64_t ip = baseAddr; ip < baseAddr + sym->size.Val(); ip++ )
{ {
@ -3618,7 +3660,6 @@ void SourceView::GatherAdditionalIpStats( uint64_t baseAddr, AddrStat& iptotalSr
} }
} }
} }
}
} }
uint32_t SourceView::CountAsmIpStats( uint64_t baseAddr, const Worker& worker, bool limitView, const View& view ) uint32_t SourceView::CountAsmIpStats( uint64_t baseAddr, const Worker& worker, bool limitView, const View& view )