Implement grouping call stack tree by function names.

This commit is contained in:
Bartosz Taudul 2019-02-06 21:56:49 +01:00
parent 044b7e1522
commit 70ea9e7712

View File

@ -7652,9 +7652,25 @@ void View::ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const
ImGui::EndChild(); ImGui::EndChild();
} }
static tracy_force_inline CallstackFrameTree* GetFrameTreeItem( std::vector<CallstackFrameTree>& tree, uint64_t idx ) static tracy_force_inline CallstackFrameTree* GetFrameTreeItem( std::vector<CallstackFrameTree>& tree, uint64_t idx, const Worker& worker, bool groupByName )
{ {
auto it = std::find_if( tree.begin(), tree.end(), [idx] ( const auto& v ) { return v.frame == idx; } ); std::vector<CallstackFrameTree>::iterator it;
if( groupByName )
{
auto& frameData = *worker.GetCallstackFrame( idx );
auto& frame = frameData.data[frameData.size-1];
auto fidx = frame.name.idx;
it = std::find_if( tree.begin(), tree.end(), [&worker, fidx] ( const auto& v ) {
auto& frameData = *worker.GetCallstackFrame( v.frame );
auto& frame = frameData.data[frameData.size-1];
return frame.name.idx == fidx;
} );
}
else
{
it = std::find_if( tree.begin(), tree.end(), [idx] ( const auto& v ) { return v.frame == idx; } );
}
if( it == tree.end() ) if( it == tree.end() )
{ {
tree.emplace_back( CallstackFrameTree { idx } ); tree.emplace_back( CallstackFrameTree { idx } );
@ -7701,14 +7717,14 @@ std::vector<CallstackFrameTree> View::GetCallstackFrameTreeBottomUp( const MemDa
auto& cs = m_worker.GetCallstack( path.first ); auto& cs = m_worker.GetCallstack( path.first );
auto base = cs.back(); auto base = cs.back();
auto treePtr = GetFrameTreeItem( root, base ); auto treePtr = GetFrameTreeItem( root, base, m_worker, m_groupCallstackTreeByNameBottomUp );
treePtr->countInclusive += path.second.cnt; treePtr->countInclusive += path.second.cnt;
treePtr->allocInclusive += path.second.mem; treePtr->allocInclusive += path.second.mem;
treePtr->callstacks.emplace( path.first ); treePtr->callstacks.emplace( path.first );
for( int i = int( cs.size() ) - 2; i >= 0; i-- ) for( int i = int( cs.size() ) - 2; i >= 0; i-- )
{ {
treePtr = GetFrameTreeItem( treePtr->children, cs[i] ); treePtr = GetFrameTreeItem( treePtr->children, cs[i], m_worker, m_groupCallstackTreeByNameBottomUp );
treePtr->countInclusive += path.second.cnt; treePtr->countInclusive += path.second.cnt;
treePtr->allocInclusive += path.second.mem; treePtr->allocInclusive += path.second.mem;
treePtr->callstacks.emplace( path.first ); treePtr->callstacks.emplace( path.first );
@ -7729,14 +7745,14 @@ std::vector<CallstackFrameTree> View::GetCallstackFrameTreeTopDown( const MemDat
auto& cs = m_worker.GetCallstack( path.first ); auto& cs = m_worker.GetCallstack( path.first );
auto base = cs.front(); auto base = cs.front();
auto treePtr = GetFrameTreeItem( root, base ); auto treePtr = GetFrameTreeItem( root, base, m_worker, m_groupCallstackTreeByNameTopDown );
treePtr->countInclusive += path.second.cnt; treePtr->countInclusive += path.second.cnt;
treePtr->allocInclusive += path.second.mem; treePtr->allocInclusive += path.second.mem;
treePtr->callstacks.emplace( path.first ); treePtr->callstacks.emplace( path.first );
for( int i = 1; i < cs.size(); i++ ) for( int i = 1; i < cs.size(); i++ )
{ {
treePtr = GetFrameTreeItem( treePtr->children, cs[i] ); treePtr = GetFrameTreeItem( treePtr->children, cs[i], m_worker, m_groupCallstackTreeByNameTopDown );
treePtr->countInclusive += path.second.cnt; treePtr->countInclusive += path.second.cnt;
treePtr->allocInclusive += path.second.mem; treePtr->allocInclusive += path.second.mem;
treePtr->callstacks.emplace( path.first ); treePtr->callstacks.emplace( path.first );