Stats objects have the following methods:
When more than one key is provided, then additional keys are used as secondary criteria when the there is equality in all keys selected before them. For example, "sort_stats('name', 'file')" will sort all the entries according to their function name, and resolve all ties (identical function names) by sorting by file name.
Abbreviations can be used for any key names, as long as the abbreviation is unambiguous. The following are the keys currently defined:
||primitive call count|
Note that all sorts on statistics are in descending order (placing
most time consuming items first), where as name, file, and line number
searches are in ascending order (alphabetical). The subtle
'stdname' is that the
standard name is a sort of the name as printed, which means that the
embedded line numbers get compared in an odd way. For example, lines
3, 20, and 40 would (if the file names were the same) appear in the
string order 20, 3 and 40. In contrast,
'nfl' does a numeric
compare of the line numbers. In fact,
sort_stats('nfl') is the
sort_stats('name', 'file', 'line').
For compatibility with the old profiler, the numeric arguments
2 are permitted. They are
'cumulative' respectively. If this old style format (numeric)
is used, only one sort key (the numeric key) will be used, and
additional arguments will be silently ignored.
The order of the printing is based on the last sort_stats() operation done on the object (subject to caveats in add() and strip_dirs()).
The arguments provided (if any) can be used to limit the list down to the significant entries. Initially, the list is taken to be the complete set of profiled functions. Each restriction is either an integer (to select a count of lines), or a decimal fraction between 0.0 and 1.0 inclusive (to select a percentage of lines), or a regular expression (to pattern match the standard name that is printed; as of Python 1.5b1, this uses the Perl-style regular expression syntax defined by the re module). If several restrictions are provided, then they are applied sequentially. For example:
would first limit the printing to first 10% of list, and then only print functions that were part of filename ".*foo:". In contrast, the command:
would limit the list to all functions having file names ".*foo:", and then proceed to only print the first 10% of them.
None. The method is still defined for backward compatibility.