Skip to content
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

Make Profile.print_stats support sorting by mutiple values #69990

Closed
wdv4758h mannequin opened this issue Dec 5, 2015 · 6 comments
Closed

Make Profile.print_stats support sorting by mutiple values #69990

wdv4758h mannequin opened this issue Dec 5, 2015 · 6 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@wdv4758h
Copy link
Mannequin

wdv4758h mannequin commented Dec 5, 2015

BPO 25804
Nosy @birkenfeld, @JelleZijlstra, @DanielNoord
Files
  • print_stats.patch: enhance print_stats
  • print_stats_with_test.patch: refactor patch & add tests
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2015-12-05.08:25:52.232>
    labels = ['type-feature', 'library']
    title = 'Make Profile.print_stats support sorting by mutiple values'
    updated_at = <Date 2022-03-16.08:34:17.207>
    user = 'https://bugs.python.org/wdv4758h'

    bugs.python.org fields:

    activity = <Date 2022-03-16.08:34:17.207>
    actor = 'danielnoord'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2015-12-05.08:25:52.232>
    creator = 'wdv4758h'
    dependencies = []
    files = ['41247', '41249']
    hgrepos = []
    issue_num = 25804
    keywords = ['patch']
    message_count = 5.0
    messages = ['255935', '255940', '255952', '267273', '415329']
    nosy_count = 5.0
    nosy_names = ['georg.brandl', 'SilentGhost', 'wdv4758h', 'JelleZijlstra', 'danielnoord']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'test needed'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue25804'
    versions = ['Python 3.6']

    Linked PRs

    @wdv4758h
    Copy link
    Mannequin Author

    wdv4758h mannequin commented Dec 5, 2015

    Currently, the result of profile.run can not easily sort by mutiple values with "sort" keyword argument. Following code will work with this patch.

    >>> import cProfile
    >>> cProfile.run('42**42', sort=('tottime', 'stdname'))
             3 function calls in 0.000 seconds

    Ordered by: internal time, standard name

    ncalls tottime percall cumtime percall filename:lineno(function)
    1 0.000 0.000 0.000 0.000 {built-in method builtins.exec}
    1 0.000 0.000 0.000 0.000 <string>:1(<module>)
    1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}

    >>> import cProfile
    >>> cProfile.run('42**42', sort=('tottime', 'stdname'))
             3 function calls in 0.000 seconds

    Ordered by: internal time, standard name

    ncalls tottime percall cumtime percall filename:lineno(function)
    1 0.000 0.000 0.000 0.000 {built-in method builtins.exec}
    1 0.000 0.000 0.000 0.000 <string>:1(<module>)
    1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}

    >>> import profile
    >>> profile.run('42**42', sort=('tottime', 'stdname'))
             4 function calls in 0.000 seconds

    Ordered by: internal time, standard name

    ncalls tottime percall cumtime percall filename:lineno(function)
    1 0.000 0.000 0.000 0.000 profile:0(42**42)
    1 0.000 0.000 0.000 0.000 :0(exec)
    1 0.000 0.000 0.000 0.000 :0(setprofile)
    1 0.000 0.000 0.000 0.000 <string>:1(<module>)
    0 0.000 0.000 profile:0(profiler)

    @wdv4758h wdv4758h mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Dec 5, 2015
    @SilentGhost
    Copy link
    Mannequin

    SilentGhost mannequin commented Dec 5, 2015

    It would be good to add test for this.

    @wdv4758h
    Copy link
    Mannequin Author

    wdv4758h mannequin commented Dec 5, 2015

    Attached refactored patch with tests.

    @JelleZijlstra
    Copy link
    Member

    Patch looks good to me

    @DanielNoord
    Copy link
    Mannequin

    DanielNoord mannequin commented Mar 16, 2022

    @wdv4758h, do you think you will be able to resubmit the patch to Github? This would probably still be a useful addition and some review has already been done.

    If not, I could pick up the patch and re-submit, but I don't want to take credit for your work unnecessarily.

    @furkanonder
    Copy link
    Sponsor Contributor

    furkanonder commented May 22, 2023

    The PR is ready for review.

    serhiy-storchaka pushed a commit that referenced this issue Feb 16, 2024
    woodruffw pushed a commit to woodruffw-forks/cpython that referenced this issue Mar 4, 2024
    diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants