← Back to DAGDA | Support | Source: https://github.com/python/cpython/pull/5103/commits/ef409c2802e1c8ade738021e073f0e78b0c07ac6
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change SortKey.MODULE to SortKey.FILENAME
  • Loading branch information
mwidjaja committed Jan 26, 2018
commit ef409c2802e1c8ade738021e073f0e78b0c07ac6
6 changes: 3 additions & 3 deletions Doc/library/profile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ statistics for the top ten functions.

You might also try::

p.sort_stats(SortKey.MODULE).print_stats('__init__')
p.sort_stats(SortKey.FILENAME).print_stats('__init__')

This will sort all the statistics by file name, and then print out statistics
for only the class init methods (since they are spelled with ``__init__`` in
Expand Down Expand Up @@ -393,7 +393,7 @@ Analysis of the profiler data is done using the :class:`~pstats.Stats` class.
+------------------+---------------------+----------------------+
| ``'filename'`` | N/A | file name |
+------------------+---------------------+----------------------+
| ``'module'`` | SortKey.MODULE | file name |
| ``'module'`` | SortKey.FILENAME | file name |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move SortKey.FILENAME up one line to the 'filename' entry, change the 'module' entry to N/A, and we're done! Thank you!

+------------------+---------------------+----------------------+
| ``'ncalls'`` | N/A | call count |
+------------------+---------------------+----------------------+
Expand Down Expand Up @@ -421,7 +421,7 @@ Analysis of the profiler data is done using the :class:`~pstats.Stats` class.
the file names were the same) appear in the string order 20, 3 and 40.
In contrast, ``SortKey.NFL`` does a numeric compare of the line numbers.
In fact, ``sort_stats(SortKey.NFL)`` is the same as
``sort_stats(SortKey.NAME, SortKey.MODULE, SortKey.LINE)``.
``sort_stats(SortKey.NAME, SortKey.FILENAME, SortKey.LINE)``.

For backward-compatibility reasons, the numeric arguments ``-1``, ``0``,
``1``, and ``2`` are permitted. They are interpreted as ``'stdname'``,
Expand Down
2 changes: 1 addition & 1 deletion Lib/pstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
class SortKey(str, Enum):
CALLS = 'calls', 'ncalls'
CUMULATIVE = 'cumulative', 'cumtime'
MODULE = 'module', 'filename'
FILENAME = 'filename', 'module'
LINE = 'line'
NAME = 'name'
NFL = 'nfl'
Expand Down