| 670 | pass |
| 671 | |
| 672 | class ProfileBrowser(cmd.Cmd): |
| 673 | def __init__(self, profile=None): |
| 674 | cmd.Cmd.__init__(self) |
| 675 | self.prompt = "% " |
| 676 | self.stats = None |
| 677 | self.stream = sys.stdout |
| 678 | if profile is not None: |
| 679 | self.do_read(profile) |
| 680 | |
| 681 | def generic(self, fn, line): |
| 682 | args = line.split() |
| 683 | processed = [] |
| 684 | for term in args: |
| 685 | try: |
| 686 | processed.append(int(term)) |
| 687 | continue |
| 688 | except ValueError: |
| 689 | pass |
| 690 | try: |
| 691 | frac = float(term) |
| 692 | if frac > 1 or frac < 0: |
| 693 | print("Fraction argument must be in [0, 1]", file=self.stream) |
| 694 | continue |
| 695 | processed.append(frac) |
| 696 | continue |
| 697 | except ValueError: |
| 698 | pass |
| 699 | processed.append(term) |
| 700 | if self.stats: |
| 701 | getattr(self.stats, fn)(*processed) |
| 702 | else: |
| 703 | print("No statistics object is loaded.", file=self.stream) |
| 704 | return 0 |
| 705 | def generic_help(self): |
| 706 | print("Arguments may be:", file=self.stream) |
| 707 | print("* An integer maximum number of entries to print.", file=self.stream) |
| 708 | print("* A decimal fractional number between 0 and 1, controlling", file=self.stream) |
| 709 | print(" what fraction of selected entries to print.", file=self.stream) |
| 710 | print("* A regular expression; only entries with function names", file=self.stream) |
| 711 | print(" that match it are printed.", file=self.stream) |
| 712 | |
| 713 | def do_add(self, line): |
| 714 | if self.stats: |
| 715 | try: |
| 716 | self.stats.add(line) |
| 717 | except OSError as e: |
| 718 | print("Failed to load statistics for %s: %s" % (line, e), file=self.stream) |
| 719 | else: |
| 720 | print("No statistics object is loaded.", file=self.stream) |
| 721 | return 0 |
| 722 | def help_add(self): |
| 723 | print("Add profile info from given file to current statistics object.", file=self.stream) |
| 724 | |
| 725 | def do_callees(self, line): |
| 726 | return self.generic('print_callees', line) |
| 727 | def help_callees(self): |
| 728 | print("Print callees statistics from the current stat object.", file=self.stream) |
| 729 | self.generic_help() |
no outgoing calls
no test coverage detected
searching dependent graphs…