Skip to content

Commit 75eee1d

Browse files
authored
bpo-34861: Make cumtime the default sorting key for cProfile (GH-31929)
1 parent 6881ea9 commit 75eee1d

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

Doc/library/profile.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,23 @@ your system.)
6666
The above action would run :func:`re.compile` and print profile results like
6767
the following::
6868

69-
197 function calls (192 primitive calls) in 0.002 seconds
69+
214 function calls (207 primitive calls) in 0.002 seconds
7070

71-
Ordered by: standard name
71+
Ordered by: cumulative time
7272

7373
ncalls tottime percall cumtime percall filename:lineno(function)
74+
1 0.000 0.000 0.002 0.002 {built-in method builtins.exec}
7475
1 0.000 0.000 0.001 0.001 <string>:1(<module>)
75-
1 0.000 0.000 0.001 0.001 re.py:212(compile)
76-
1 0.000 0.000 0.001 0.001 re.py:268(_compile)
77-
1 0.000 0.000 0.000 0.000 sre_compile.py:172(_compile_charset)
78-
1 0.000 0.000 0.000 0.000 sre_compile.py:201(_optimize_charset)
79-
4 0.000 0.000 0.000 0.000 sre_compile.py:25(_identityfunction)
80-
3/1 0.000 0.000 0.000 0.000 sre_compile.py:33(_compile)
81-
82-
The first line indicates that 197 calls were monitored. Of those calls, 192
76+
1 0.000 0.000 0.001 0.001 re.py:250(compile)
77+
1 0.000 0.000 0.001 0.001 re.py:289(_compile)
78+
1 0.000 0.000 0.000 0.000 sre_compile.py:759(compile)
79+
1 0.000 0.000 0.000 0.000 sre_parse.py:937(parse)
80+
1 0.000 0.000 0.000 0.000 sre_compile.py:598(_code)
81+
1 0.000 0.000 0.000 0.000 sre_parse.py:435(_parse_sub)
82+
83+
The first line indicates that 214 calls were monitored. Of those calls, 207
8384
were :dfn:`primitive`, meaning that the call was not induced via recursion. The
84-
next line: ``Ordered by: standard name``, indicates that the text string in the
85+
next line: ``Ordered by: cumulative name``, indicates that the text string in the
8586
far right column was used to sort the output. The column headings include:
8687

8788
ncalls

Lib/cProfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def main():
140140
help="Save stats to <outfile>", default=None)
141141
parser.add_option('-s', '--sort', dest="sort",
142142
help="Sort order when printing to stdout, based on pstats.Stats class",
143-
default=-1,
143+
default=2,
144144
choices=sorted(pstats.Stats.sort_arg_dict_default))
145145
parser.add_option('-m', dest="module", action="store_true",
146146
help="Profile a library module", default=False)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Made cumtime the default sorting key for cProfile

0 commit comments

Comments
 (0)