Add calculation of child stats to source view.

This commit is contained in:
Bartosz Taudul 2021-11-27 14:42:23 +01:00
parent 85f755f3f5
commit 6a7b4e6066
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 55 additions and 0 deletions

View File

@ -4589,6 +4589,59 @@ void SourceView::GatherAdditionalIpStats( uint64_t baseAddr, AddrStatData& as, c
} }
} }
void SourceView::GatherChildStats( uint64_t baseAddr, unordered_flat_map<uint64_t, uint32_t>& map, Worker& worker, bool limitView, const View& view )
{
if( !worker.AreSymbolSamplesReady() ) return;
auto sym = worker.GetSymbolData( baseAddr );
if( !sym ) return;
if( limitView )
{
for( uint64_t ip = baseAddr; ip < baseAddr + sym->size.Val(); ip++ )
{
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.time.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.time.Val() < rhs; } );
while( it != end )
{
auto child = worker.GetSymbolForAddress( it->addr );
auto mit = map.find( child );
if( mit == map.end() )
{
map.emplace( child, 1 );
}
else
{
mit->second++;
}
++it;
}
}
}
else
{
for( uint64_t ip = baseAddr; ip < baseAddr + sym->size.Val(); ip++ )
{
auto cp = worker.GetChildSamples( ip );
if( !cp ) continue;
for( auto& s : *cp )
{
auto child = worker.GetSymbolForAddress( s.addr );
auto mit = map.find( child );
if( mit == map.end() )
{
map.emplace( child, 1 );
}
else
{
mit->second++;
}
}
}
}
}
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 )
{ {
if( limitView ) if( limitView )

View File

@ -177,6 +177,8 @@ private:
void GatherIpHwStats( AddrStatData& as, Worker& worker, const View& view, CostType cost ); void GatherIpHwStats( AddrStatData& as, Worker& worker, const View& view, CostType cost );
void GatherIpStats( uint64_t baseAddr, AddrStatData& as, const Worker& worker, bool limitView, const View& view ); void GatherIpStats( uint64_t baseAddr, AddrStatData& as, const Worker& worker, bool limitView, const View& view );
void GatherAdditionalIpStats( uint64_t baseAddr, AddrStatData& as, const Worker& worker, bool limitView, const View& view ); void GatherAdditionalIpStats( uint64_t baseAddr, AddrStatData& as, const Worker& worker, bool limitView, const View& view );
void GatherChildStats( uint64_t baseAddr, unordered_flat_map<uint64_t, uint32_t>& vec, Worker& worker, bool limitView, const View& view );
uint32_t CountAsmIpStats( uint64_t baseAddr, const Worker& worker, bool limitView, const View& view ); uint32_t CountAsmIpStats( uint64_t baseAddr, const Worker& worker, bool limitView, const View& view );
void CountHwStats( AddrStatData& as, Worker& worker, const View& view ); void CountHwStats( AddrStatData& as, Worker& worker, const View& view );