Visitar URL original
Make Profile.print_stats support sorting by mutiple values · Issue #69990 · python/cpython · GitHub
Skip to content

Make Profile.print_stats support sorting by mutiple values #69990

Closed

Description

@wdv4758h
mannequin
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

    Activity

    1. wdv4758h commented on Dec 5, 2015

      wdv4758hmannequin
      MannequinAuthor

      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)

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Dec 5, 2015
    3. SilentGhost commented on Dec 5, 2015

      SilentGhostmannequin
      Mannequin

      It would be good to add test for this.

    4. wdv4758h commented on Dec 5, 2015

      wdv4758hmannequin
      MannequinAuthor

      Attached refactored patch with tests.

    5. JelleZijlstra commented on Jun 4, 2016

      @JelleZijlstra
      Member

      Patch looks good to me

    6. DanielNoord commented on Mar 16, 2022

      DanielNoordmannequin
      Mannequin

      @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.

    7. transferred this issue fromon Apr 10, 2022
    8. furkanonder commented on May 22, 2023

      @furkanonder
      Contributor

      The PR is ready for review.

    9. added a commit that references this issue on Feb 16, 2024
    10. added a commit that references this issue on Mar 4, 2024
    11. added a commit that references this issue on Apr 17, 2024
    12. added a commit that references this issue on Jan 22, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions