Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict counts/timings on the callee tab to calls by caller #12

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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