-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
bpo-34861: better cProfile CLI defaults: sort by time, restrict to top 20 #13083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
adds option -n to restrict to top n lines (defaults to 20 for CLI) set default of -s to sort by time (instead of unsorted) "python3 -m cProfile foo.py" directly usable.
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thank you for the pull request and for the patience. I've left a couple of comments about the changes.
Just a question: did yo test it? If didn't, please provide it. Thank you.
Furthermore, the Doc and perhaps the docstring should be improved adding the parameter and explaining what it does.
I'm not a core-dev, so feel free to don't follow my tips.
|
||
def runctx(statement, globals, locals, filename=None, sort=-1): | ||
def runctx(statement, globals, locals, filename=None, sort=-1, | ||
numresults=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, indent numresults
under statement
.
@@ -185,7 +190,8 @@ def main(): | |||
'__package__': None, | |||
'__cached__': None, | |||
} | |||
runctx(code, globs, None, options.outfile, options.sort) | |||
runctx(code, globs, None, options.outfile, options.sort, | |||
options.numresults) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, indent options.numresults
under code
.
|
||
def runctx(statement, globals, locals, filename=None, sort=-1): | ||
def runctx(statement, globals, locals, filename=None, sort=-1, | ||
numresults=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same for this row. :)
@@ -605,7 +610,8 @@ def main(): | |||
'__package__': None, | |||
'__cached__': None, | |||
} | |||
runctx(code, globs, None, options.outfile, options.sort) | |||
runctx(code, globs, None, options.outfile, options.sort, | |||
options.numresults) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent options.numresults
under code
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that #31929 made the default sort order cumtime. Any interest in merging main and picking this back up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting changes as per above
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@hauntsaninja personally I like |
The following commit authors need to sign the Contributor License Agreement: |
adds option -n to restrict to top n lines (defaults to 20 for CLI)
set default of -s to sort by time (instead of unsorted)
makes "python3 -m cProfile foo.py" directly usable.
https://bugs.python.org/issue34861