MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / ProfileBrowser

Class ProfileBrowser

tools/python-3.11.9-amd64/Lib/pstats.py:620–764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

618 pass
619
620 class ProfileBrowser(cmd.Cmd):
621 def __init__(self, profile=None):
622 cmd.Cmd.__init__(self)
623 self.prompt = "% "
624 self.stats = None
625 self.stream = sys.stdout
626 if profile is not None:
627 self.do_read(profile)
628
629 def generic(self, fn, line):
630 args = line.split()
631 processed = []
632 for term in args:
633 try:
634 processed.append(int(term))
635 continue
636 except ValueError:
637 pass
638 try:
639 frac = float(term)
640 if frac > 1 or frac < 0:
641 print("Fraction argument must be in [0, 1]", file=self.stream)
642 continue
643 processed.append(frac)
644 continue
645 except ValueError:
646 pass
647 processed.append(term)
648 if self.stats:
649 getattr(self.stats, fn)(*processed)
650 else:
651 print("No statistics object is loaded.", file=self.stream)
652 return 0
653 def generic_help(self):
654 print("Arguments may be:", file=self.stream)
655 print("* An integer maximum number of entries to print.", file=self.stream)
656 print("* A decimal fractional number between 0 and 1, controlling", file=self.stream)
657 print(" what fraction of selected entries to print.", file=self.stream)
658 print("* A regular expression; only entries with function names", file=self.stream)
659 print(" that match it are printed.", file=self.stream)
660
661 def do_add(self, line):
662 if self.stats:
663 try:
664 self.stats.add(line)
665 except OSError as e:
666 print("Failed to load statistics for %s: %s" % (line, e), file=self.stream)
667 else:
668 print("No statistics object is loaded.", file=self.stream)
669 return 0
670 def help_add(self):
671 print("Add profile info from given file to current statistics object.", file=self.stream)
672
673 def do_callees(self, line):
674 return self.generic('print_callees', line)
675 def help_callees(self):
676 print("Print callees statistics from the current stat object.", file=self.stream)
677 self.generic_help()

Callers 1

pstats.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected