diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2001-04-26 07:32:38 (GMT) |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2001-04-26 07:32:38 (GMT) |
commit | 53b809d6739249c02436d560fa69d7245039b624 (patch) | |
tree | 0599ea6ac7e8984e670f7e3e820b07a5446f6f82 /Lib/pstats.py | |
parent | c1218bc0148bbfb2b89fa59d27a91fc3febb1da2 (diff) | |
download | cpython-53b809d6739249c02436d560fa69d7245039b624.zip cpython-53b809d6739249c02436d560fa69d7245039b624.tar.gz cpython-53b809d6739249c02436d560fa69d7245039b624.tar.bz2 |
Added more help, and recovery from misspelled sort key arguments.
Diffstat (limited to 'Lib/pstats.py')
-rw-r--r-- | Lib/pstats.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Lib/pstats.py b/Lib/pstats.py index da3aeb7..19478d6 100644 --- a/Lib/pstats.py +++ b/Lib/pstats.py @@ -568,22 +568,31 @@ if __name__ == '__main__': else: print "No statistics object is loaded." return 0 + def generic_help(self): + print "Arguments may be:" + print "* An integer maximum number of entries to print." + print "* A decimal fractional number between 0 and 1, controlling" + print " what fraction of selected entries to print." + print "* A regular expression; only entries with function names" + print " that match it are printed." def do_add(self, line): self.stats.add(line) return 0 def help_add(self): - print "Add profile info from given file to current stastics object." + print "Add profile info from given file to current statistics object." def do_callees(self, line): return self.generic('print_callees', line) def help_callees(self): print "Print callees statistics from the current stat object." + self.generic_help() def do_callers(self, line): return self.generic('print_callers', line) def help_callers(self): print "Print callers statistics from the current stat object." + self.generic_help() def do_EOF(self, line): print "" @@ -619,15 +628,23 @@ if __name__ == '__main__': print "Reverse the sort order of the profiling report." def do_sort(self, line): - apply(self.stats.sort_stats, line.split()) + abbrevs = self.stats.get_sort_arg_defs().keys() + if line and not filter(lambda x,a=abbrevs: x not in a,line.split()): + apply(self.stats.sort_stats, line.split()) + else: + print "Valid sort keys (unique prefixes are accepted):" + for (key, value) in Stats.sort_arg_dict_default.items(): + print "%s -- %s" % (key, value[1]) return 0 def help_sort(self): print "Sort profile data according to specified keys." + print "(Typing `sort' without arguments lists valid keys.)" def do_stats(self, line): return self.generic('print_stats', line) def help_stats(self): print "Print statistics from the current stat object." + self.generic_help() def do_strip(self, line): self.stats.strip_dirs() |