Prune the profile
(self, node_thres, edge_thres)
| 521 | self[outevent] = 1.0 |
| 522 | |
| 523 | def prune(self, node_thres, edge_thres): |
| 524 | """Prune the profile""" |
| 525 | |
| 526 | # compute the prune ratios |
| 527 | for function in self.functions.values(): |
| 528 | try: |
| 529 | function.weight = function[TOTAL_TIME_RATIO] |
| 530 | except UndefinedEvent: |
| 531 | pass |
| 532 | |
| 533 | for call in function.calls.values(): |
| 534 | callee = self.functions[call.callee_id] |
| 535 | |
| 536 | if TOTAL_TIME_RATIO in call: |
| 537 | # handle exact cases first |
| 538 | call.weight = call[TOTAL_TIME_RATIO] |
| 539 | else: |
| 540 | try: |
| 541 | # make a safe estimate |
| 542 | call.weight = min(function[TOTAL_TIME_RATIO], callee[TOTAL_TIME_RATIO]) |
| 543 | except UndefinedEvent: |
| 544 | pass |
| 545 | |
| 546 | # prune the nodes |
| 547 | for function_id in list(self.functions.keys()): |
| 548 | function = self.functions[function_id] |
| 549 | if function.weight is not None: |
| 550 | if function.weight < node_thres: |
| 551 | del self.functions[function_id] |
| 552 | |
| 553 | # prune the egdes |
| 554 | for function in self.functions.values(): |
| 555 | for callee_id in list(function.calls.keys()): |
| 556 | call = function.calls[callee_id] |
| 557 | if callee_id not in self.functions or call.weight is not None and call.weight < edge_thres: |
| 558 | del function.calls[callee_id] |
| 559 | |
| 560 | def dump(self): |
| 561 | for function in self.functions.values(): |
no test coverage detected