Processes collected stats for UI.
(prof)
| 16 | |
| 17 | @staticmethod |
| 18 | def _transform_stats(prof): |
| 19 | """Processes collected stats for UI.""" |
| 20 | records = [] |
| 21 | for info, params in prof.stats.items(): |
| 22 | filename, lineno, funcname = info |
| 23 | cum_calls, num_calls, time_per_call, cum_time, _ = params |
| 24 | if prof.total_tt == 0: |
| 25 | percentage = 0 |
| 26 | else: |
| 27 | percentage = round(100 * (cum_time / prof.total_tt), 4) |
| 28 | cum_time = round(cum_time, 4) |
| 29 | func_name = '%s @ %s' % (funcname, filename) |
| 30 | color_hash = base_profiler.hash_name(func_name) |
| 31 | records.append( |
| 32 | (filename, lineno, funcname, cum_time, percentage, num_calls, |
| 33 | cum_calls, time_per_call, filename, color_hash)) |
| 34 | return sorted(records, key=operator.itemgetter(4), reverse=True) |
| 35 | |
| 36 | def _profile_package(self): |
| 37 | """Runs cProfile on a package.""" |
no outgoing calls