Skip to content

Commit

Permalink
restricting counts/timings on the callee tab to calls by caller
Browse files Browse the repository at this point in the history
  • Loading branch information
asodeur committed Aug 28, 2020
1 parent 9bc349a commit 23c58ab
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions runsnakerun/pstatsloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def load(self, stats):
log.info('Null row: %s', func)
for row in six.itervalues(rows):
row.weave(rows)
for row in six.itervalues(rows):
row.fix_children()
return self.find_root(rows)

def load_functions(self):
Expand Down Expand Up @@ -269,6 +271,29 @@ def weave(self, rows):
self.parents.append(parent)
parent.children.append(self)

def fix_children(self, seen=None):
"""make sure rows in .children only contain call count/timings when called by self"""
seen = set() if seen is None else seen
if self in seen:
return self

seen.add(self)

children = []
for c in self.children:
call_timings = c.callers.get(self.key)
if call_timings is None:
children.append(c)
else:
child_node = PStatRow(c.key, (*call_timings, c.callers))
seen.add(child_node)
child_node.parents = c.parents
child_node.children = [cc.fix_children(seen) for cc in c.children]
children.append(child_node)

self.children = children
return self

def child_cumulative_time(self, child):
total = self.cumulative
if total:
Expand Down

0 comments on commit 23c58ab

Please sign in to comment.