gh-69990: Make Profile.print_stats support sorting by multiple values (GH-104590)

Co-authored-by: Chiu-Hsiang Hsu
This commit is contained in:
Furkan Onder 2024-02-16 15:03:46 +03:00 committed by GitHub
parent 351c103134
commit 2a7a0020c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 4 deletions

View file

@ -41,7 +41,9 @@ class Profile(_lsprof.Profiler):
def print_stats(self, sort=-1):
import pstats
pstats.Stats(self).strip_dirs().sort_stats(sort).print_stats()
if not isinstance(sort, tuple):
sort = (sort,)
pstats.Stats(self).strip_dirs().sort_stats(*sort).print_stats()
def dump_stats(self, file):
import marshal