68
68
_info[this].append(cost)
71
def log_stack_info(out_file):
71
def log_stack_info(out_file, sorted=True):
72
72
# Find all of the roots with import = 0
73
73
out_file.write('cum inline name\t\t\tscope\t\t\tframe\n')
74
todo = [key for key,value in _info.iteritems() if value[0] == 0]
74
todo = [(value[-1], key) for key,value in _info.iteritems() if value[0] == 0]
80
cum_time, cur = todo.pop()
78
81
children = _total_stack[cur]
81
86
# Compute the module time by removing the children times
82
87
mod_time = info[-1]
83
88
for child in children:
84
89
c_info = _info[child]
85
90
mod_time -= c_info[-1]
91
c_times.append((c_info[-1], child))
87
93
scope_name = info[3]
88
94
if scope_name is None:
89
txt = '%-64s' % (cur[1],)
95
txt = '%-62s' % (cur[1][:64],)
91
txt = '%-28s\tfor %-24s' % (cur[1], scope_name)
97
txt = '%-27s\tfor %-24s' % (cur[1], scope_name)
92
98
# indent, cum_time, mod_time, name,
93
99
# scope_name, frame_name, frame_lineno
94
100
out_file.write('%5.1f %5.1f %s %s\t@ %s:%d\n'
95
101
% (info[-1]*1000., mod_time*1000., '+'*info[0],
96
102
txt, info[1], info[2]))
98
todo.extend(reversed(children))
101
111
_real_import = __import__