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
7 changes: 4 additions & 3 deletions flameprof.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ def prepare(funcs, calls, threshold=0.0001):
bblocks = []
block_counts = Counter()

def _counts(parent, visited, level=0):
todo = [('root', set(), 0)]
while todo:
parent, visited, level = todo.pop(-1)
for child in funcs[parent]['calls']:
k = parent, child
block_counts[k] += 1
if block_counts[k] < 2:
if k not in visited:
_counts(child, visited | {k}, level+1)
todo.append((child, visited | {k}, level+1))

def _calc(parent, timings, level, origin, visited, trace=(), pccnt=1, pblock=None):
childs = funcs[parent]['calls']
Expand Down Expand Up @@ -227,7 +229,6 @@ def _calc_back(names, level, to, origin, visited, pw):
origin += ttt

maxw = funcs['root']['stat'][3] * 1.0
_counts('root', set())
_calc('root', (1, 1, maxw, maxw), 0, 0, set())
_calc_back((f for f in funcs if f != 'root'), 0, None, 0, set(), 0)

Expand Down