classification
Title: cProfile does not take its result headers as sort arguments
Type: enhancement Stage: resolved
Components: Documentation, Library (Lib) Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: asvetlov Nosy List: ArneBab, asvetlov, python-dev
Priority: normal Keywords: patch

Created on 2012-05-24 14:19 by ArneBab, last changed 2012-11-01 16:51 by asvetlov. This issue is now closed.

Files
File name Uploaded Description Edit
2.7-0-pcalls.diff ArneBab, 2012-05-24 14:19 2.7-0-pcalls.diff review
2.7-1-headings-sortable.diff ArneBab, 2012-05-24 14:19 2.7-1-headings-sortable.diff
3.2-0-pcalls.diff ArneBab, 2012-05-24 14:19 3.2-0-pcalls.diff review
3.2-1-headings-sortable.diff ArneBab, 2012-05-24 14:20 3.2-1-headings-sortable.diff
profile-docs-3.2.diff ArneBab, 2012-10-08 08:44 patch for updating the docs
profile-docs-2.7.diff ArneBab, 2012-10-08 08:45 patch for updating the docs review
sort-argument-3.2.diff ArneBab, 2012-10-08 14:47
sort-argument-2.7.diff ArneBab, 2012-10-08 14:50
Messages (20)
msg161508 - (view) Author: Arne Babenhauserheide (ArneBab) * Date: 2012-05-24 14:19
cProfile reports the profiling result in a table with the headers

  ncalls  tottime  percall  cumtime  percall filename:lineno(function)

The respective arguments are 

  calls   time     -        cumulative -     nfl

Since I had to lookup these different names everytime I used cProfile, I think that it should take the table headings as argument aliases.

Also there is inconsistent naming of pcalls between docs and code.

In the docs of Stats.sort_stats pcalls is named primitive call count.
In the code at Stats.sort_arg_dict_default it was just named call count.

I created 4 patches to fix that in Python 2.7 and Python 3.2. The first is attached here, the later will be attached to comments. 

They apply to 822d7a1f8885 for 2.7 and 89b699e68fa2 for 3.2.

I also created a patch for adding percall sorting, but that requires more invasive changes and I did not see a simple name to distinguish between the two bycall headings.
msg169983 - (view) Author: Arne Babenhauserheide (ArneBab) * Date: 2012-09-07 10:40
What would be the best way to get this patch reviewed?
msg169984 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-09-07 10:47
I'll take a look next week if nobody else do it before.
msg170018 - (view) Author: Arne Babenhauserheide (ArneBab) * Date: 2012-09-07 23:17
Thank you!
msg170879 - (view) Author: Arne Babenhauserheide (ArneBab) * Date: 2012-09-21 11:02
Did you get to taking a look?

Is there anything I should change?
msg172311 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-10-07 15:59
New changeset cc3e27b7da41 by Andrew Svetlov in branch '2.7':
Issue #14900: Distuguish call count and primitive call count in pstat output.
http://hg.python.org/cpython/rev/cc3e27b7da41

New changeset 410e92589164 by Andrew Svetlov in branch '3.2':
Issue #14900: Distuguish call count and primitive call count in pstat output.
http://hg.python.org/cpython/rev/410e92589164

New changeset fb216fee32db by Andrew Svetlov in branch '3.3':
Merge issue #14900: Distuguish call count and primitive call count in pstat output.
http://hg.python.org/cpython/rev/fb216fee32db

New changeset bc658b6a1d4e by Andrew Svetlov in branch 'default':
Issue #14900: Distuguish call count and primitive call count in pstat output.
http://hg.python.org/cpython/rev/bc658b6a1d4e
msg172312 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-07 16:02
I definitely agree with renaming "call count" to "primitive call count".
Thank you for patch.

BTW please fill Python Contributor Agreement: http://www.python.org/psf/contrib/
msg172315 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-10-07 16:23
New changeset 69b310f7acfa by Andrew Svetlov in branch '2.7':
Issue #14900: Add aliases for sorting params for pstat to follow column names from pstat output.
http://hg.python.org/cpython/rev/69b310f7acfa

New changeset 511a3c51731e by Andrew Svetlov in branch '3.2':
Issue #14900: Add aliases for sorting params for pstat to follow column names from pstat output.
http://hg.python.org/cpython/rev/511a3c51731e

New changeset 29d4ac311627 by Andrew Svetlov in branch '3.3':
Merge issue #14900: Add aliases for sorting params for pstat to follow column names from pstat output.
http://hg.python.org/cpython/rev/29d4ac311627

New changeset 7b8b1b30e5f8 by Andrew Svetlov in branch 'default':
Merge issue #14900: Add aliases for sorting params for pstat to follow column names from pstat output.
http://hg.python.org/cpython/rev/7b8b1b30e5f8
msg172317 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-07 16:24
I'm ok with aliases also.
Issue with percall can be fixed only in 3.4 via renaming one of the column.
Thanks again.
msg172318 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-07 16:28
Documentation also need to be updated to reflect changes.
msg172347 - (view) Author: Arne Babenhauserheide (ArneBab) * Date: 2012-10-07 21:37
Copyright-assignment signed and sent.

Thanks!
msg172371 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-08 10:51
Looks like you missed *sort* parameter for ".. function:: run(command, filename=None, sort=-1)"
Also it will be nice to insert link to Stats.sort_stats in doc text for run functions.
msg172382 - (view) Author: Arne Babenhauserheide (ArneBab) * Date: 2012-10-08 14:42
Jepp, I missed that. I hope the added patches clear that up.
msg172385 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-08 15:20
Sorry, I cannot figure out what hg repo version should I use to apply 
sort-argument* patches.
Can you prepare 2 cumulative patches for 2.7 and 3.2 which can be applied to current repo state?
It's CPython team policy to send patches which can be applied to pure repo if no other rule explicitly specified.
Thanks.
msg172412 - (view) Author: Arne Babenhauserheide (ArneBab) * Date: 2012-10-08 20:40
I’ll create them as soon as I get the time.

It’s not as if that’s really hard - but I still have to do it (need to diff against current tip - I already merged, so that should work without problems).
msg173207 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-17 21:21
I'm waiting for your patch.
Thanks.
msg174362 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-10-31 20:06
New changeset f263a84871de by Andrew Svetlov in branch '2.7':
Issue #14900: document added sort keys for profile stats.
http://hg.python.org/cpython/rev/f263a84871de

New changeset 52d6974fa05b by Andrew Svetlov in branch '3.2':
Issue #14900: document added sort keys for profile stats.
http://hg.python.org/cpython/rev/52d6974fa05b

New changeset 78963f00d4ad by Andrew Svetlov in branch '3.3':
Merge issue #14900: document added sort keys for profile stats.
http://hg.python.org/cpython/rev/78963f00d4ad

New changeset dd4783955353 by Andrew Svetlov in branch 'default':
Issue #14900: document added sort keys for profile stats.
http://hg.python.org/cpython/rev/dd4783955353
msg174363 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-31 20:08
Fixed. For future improvements please open new issue.
Thanks.
msg174431 - (view) Author: Arne Babenhauserheide (ArneBab) * Date: 2012-11-01 16:42
…you were faster than me (I only managed to get the repo onto my current computer yesterday and the children kept me occupied). 

Thank you!
msg174432 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-11-01 16:51
No problems!
History
Date User Action Args
2012-11-01 16:51:45asvetlovsetmessages: + msg174432
2012-11-01 16:42:20ArneBabsetmessages: + msg174431
2012-10-31 20:08:54asvetlovsetstatus: open -> closed

components: + Documentation
versions: + Python 3.3, Python 3.4
messages: + msg174363
type: enhancement
resolution: fixed
stage: resolved
2012-10-31 20:06:54python-devsetmessages: + msg174362
2012-10-17 21:21:57asvetlovsetmessages: + msg173207
2012-10-08 20:40:28ArneBabsetmessages: + msg172412
2012-10-08 15:20:20asvetlovsetmessages: + msg172385
2012-10-08 14:50:49ArneBabsetfiles: + sort-argument-2.7.diff
2012-10-08 14:50:40ArneBabsetfiles: - sort-argument-2.7.diff
2012-10-08 14:47:47ArneBabsetfiles: + sort-argument-3.2.diff
2012-10-08 14:42:58ArneBabsetfiles: - sort-argument-3.2.diff
2012-10-08 14:42:39ArneBabsetmessages: + msg172382
2012-10-08 14:37:53ArneBabsetfiles: + sort-argument-3.2.diff
2012-10-08 14:37:22ArneBabsetfiles: + sort-argument-2.7.diff
2012-10-08 10:51:27asvetlovsetmessages: + msg172371
2012-10-08 08:45:07ArneBabsetfiles: + profile-docs-2.7.diff
2012-10-08 08:44:50ArneBabsetfiles: + profile-docs-3.2.diff
2012-10-07 21:37:06ArneBabsetmessages: + msg172347
2012-10-07 16:28:29asvetlovsetmessages: + msg172318
2012-10-07 16:24:50asvetlovsetmessages: + msg172317
2012-10-07 16:23:03python-devsetmessages: + msg172315
2012-10-07 16:02:38asvetlovsetassignee: asvetlov
messages: + msg172312
2012-10-07 15:59:39python-devsetnosy: + python-dev
messages: + msg172311
2012-09-21 11:02:36ArneBabsetmessages: + msg170879
2012-09-07 23:17:31ArneBabsetmessages: + msg170018
2012-09-07 10:47:11asvetlovsetmessages: + msg169984
2012-09-07 10:40:08ArneBabsetmessages: + msg169983
2012-07-22 08:08:02asvetlovsetnosy: + asvetlov
2012-05-24 14:20:09ArneBabsetfiles: + 3.2-1-headings-sortable.diff
2012-05-24 14:19:53ArneBabsetfiles: + 3.2-0-pcalls.diff
2012-05-24 14:19:40ArneBabsetfiles: + 2.7-1-headings-sortable.diff
2012-05-24 14:19:23ArneBabcreate