This method returns an instance of StatsProfile, which contains a mapping of function names to instances of FunctionProfile. Each FunctionProfile instance holds information related to the function's profile such as how long the function took to run, how many times it was call
(self)
| 355 | return new_list, msg |
| 356 | |
| 357 | def get_stats_profile(self): |
| 358 | """This method returns an instance of StatsProfile, which contains a mapping |
| 359 | of function names to instances of FunctionProfile. Each FunctionProfile |
| 360 | instance holds information related to the function's profile such as how |
| 361 | long the function took to run, how many times it was called, etc... |
| 362 | """ |
| 363 | func_list = self.fcn_list[:] if self.fcn_list else list(self.stats.keys()) |
| 364 | if not func_list: |
| 365 | return StatsProfile(0, {}) |
| 366 | |
| 367 | total_tt = float(f8(self.total_tt)) |
| 368 | func_profiles = {} |
| 369 | stats_profile = StatsProfile(total_tt, func_profiles) |
| 370 | |
| 371 | for func in func_list: |
| 372 | cc, nc, tt, ct, callers = self.stats[func] |
| 373 | file_name, line_number, func_name = func |
| 374 | ncalls = str(nc) if nc == cc else (str(nc) + '/' + str(cc)) |
| 375 | tottime = float(f8(tt)) |
| 376 | percall_tottime = -1 if nc == 0 else float(f8(tt/nc)) |
| 377 | cumtime = float(f8(ct)) |
| 378 | percall_cumtime = -1 if cc == 0 else float(f8(ct/cc)) |
| 379 | func_profile = FunctionProfile( |
| 380 | ncalls, |
| 381 | tottime, # time spent in this function alone |
| 382 | percall_tottime, |
| 383 | cumtime, # time spent in the function plus all functions that this function called, |
| 384 | percall_cumtime, |
| 385 | file_name, |
| 386 | line_number |
| 387 | ) |
| 388 | func_profiles[func_name] = func_profile |
| 389 | |
| 390 | return stats_profile |
| 391 | |
| 392 | def get_print_list(self, sel_list): |
| 393 | width = self.max_name_len |