Skip to content
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
17 changes: 11 additions & 6 deletions runsnakerun/pstatsloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def load_pstats(filenames):
"""Given list of filenames, load pstats, potentially using a different python version

Internally will create a python2 subprocess to convert python2
pstats dumps for loading in python3, that will create a cPickle/pickle
dump and load it locally.
Expand Down Expand Up @@ -116,16 +116,21 @@ def find_root(self, rows):
cycles by sorting on cumulative time, and then collecting the traced
roots (or, if they are all on the same root, use that).
"""
maxes = sorted(list(rows.values()), key=lambda x: x.cumulative)
if not maxes:
raise RuntimeError("""Null results!""")
root = maxes[-1]
roots = [root]
roots = []
for key, value in rows.items():
if not value.parents:
log.debug('Found node root: %s', value)
if value not in roots:
roots.append(value)

if len(roots) == 0:
# use longest running function as root when we have not found a root, yet
maxes = sorted(list(rows.values()), key=lambda x: x.cumulative)
if not maxes:
raise RuntimeError("""Null results!""")
root = maxes[-1]
roots.append(root)

if len(roots) > 1:
root = PStatGroup(
directory='*', filename='*', name=_("<profiling run>"), children=roots,
Expand Down