Implement inline function aggregation.

This commit is contained in:
Bartosz Taudul 2024-03-13 19:04:34 +01:00
parent f04cdb7782
commit 3af5c7b331
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -424,6 +424,8 @@ void View::DrawSamplesStatistics( Vector<SymList>& data, int64_t timeRange, Accu
assert( inSym != nullptr ); assert( inSym != nullptr );
const auto symEnd = v.symAddr + symlen; const auto symEnd = v.symAddr + symlen;
Vector<SymList> inSymList; Vector<SymList> inSymList;
if( !m_mergeInlines )
{
while( *inSym < symEnd ) while( *inSym < symEnd )
{ {
auto sit = inlineMap.find( *inSym ); auto sit = inlineMap.find( *inSym );
@ -437,6 +439,60 @@ void View::DrawSamplesStatistics( Vector<SymList>& data, int64_t timeRange, Accu
} }
inSym++; inSym++;
} }
}
else
{
unordered_flat_map<uint32_t, uint64_t> mergeMap;
unordered_flat_map<uint64_t, SymList> outMap;
while( *inSym < symEnd )
{
auto symAddr = *inSym;
auto sit = inlineMap.find( symAddr );
auto sym = symMap.find( symAddr );
assert( sym != symMap.end() );
auto mit = mergeMap.find( sym->second.name.Idx() );
if( mit == mergeMap.end() )
{
mergeMap.emplace( sym->second.name.Idx(), symAddr );
}
else
{
symAddr = mit->second;
}
if( sit != inlineMap.end() )
{
auto oit = outMap.find( symAddr );
if( oit == outMap.end() )
{
outMap.emplace( symAddr, SymList { symAddr, sit->second.incl, sit->second.excl, 1 } );
}
else
{
oit->second.incl += sit->second.incl;
oit->second.excl += sit->second.excl;
oit->second.count++;
}
}
else
{
auto oit = outMap.find( symAddr );
if( oit == outMap.end() )
{
outMap.emplace( symAddr, SymList { symAddr, 0, 0, 1 } );
}
else
{
oit->second.count++;
}
}
inSym++;
}
inSymList.reserve( outMap.size() );
for( auto& v : outMap )
{
inSymList.push_back( v.second );
}
}
auto statIt = inlineMap.find( v.symAddr ); auto statIt = inlineMap.find( v.symAddr );
if( statIt != inlineMap.end() ) if( statIt != inlineMap.end() )
{ {