mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Added global runctx function to profile to fix SF Bug #716587
This commit is contained in:
parent
706933821c
commit
1eb4bfc657
5 changed files with 46 additions and 7 deletions
|
@ -76,6 +76,23 @@ def run(statement, filename=None):
|
|||
else:
|
||||
return prof.print_stats()
|
||||
|
||||
def runctx(statement, globals, locals, filename=None):
|
||||
"""Run statement under profiler, supplying your own globals and locals,
|
||||
optionally saving results in filename.
|
||||
|
||||
statement and filename have the same semantics as profile.run
|
||||
"""
|
||||
prof = Profile()
|
||||
try:
|
||||
prof = prof.runctx(statement, globals, locals)
|
||||
except SystemExit:
|
||||
pass
|
||||
|
||||
if filename is not None:
|
||||
prof.dump_stats(filename)
|
||||
else:
|
||||
return prof.print_stats()
|
||||
|
||||
# print help
|
||||
def help():
|
||||
for dirname in sys.path:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue