|
10 | 10 | import importlib.machinery |
11 | 11 | import importlib.util |
12 | 12 | import io |
13 | | -import profile as _pyprofile |
| 13 | +from profiling.tracing._utils import _Utils |
14 | 14 |
|
15 | 15 | # ____________________________________________________________ |
16 | 16 | # Simple interface |
17 | 17 |
|
18 | 18 | def run(statement, filename=None, sort=-1): |
19 | | - return _pyprofile._Utils(Profile).run(statement, filename, sort) |
| 19 | + """Run statement under profiler optionally saving results in filename |
| 20 | +
|
| 21 | + This function takes a single argument that can be passed to the |
| 22 | + "exec" statement, and an optional file name. In all cases this |
| 23 | + routine attempts to "exec" its first argument and gather profiling |
| 24 | + statistics from the execution. If no file name is present, then this |
| 25 | + function automatically prints a simple profiling report, sorted by the |
| 26 | + standard name string (file/line/function-name) that is presented in |
| 27 | + each line. |
| 28 | + """ |
| 29 | + return _Utils(Profile).run(statement, filename, sort) |
20 | 30 |
|
21 | 31 | def runctx(statement, globals, locals, filename=None, sort=-1): |
22 | | - return _pyprofile._Utils(Profile).runctx(statement, globals, locals, |
23 | | - filename, sort) |
| 32 | + """Run statement under profiler, supplying your own globals and locals, |
| 33 | + optionally saving results in filename. |
24 | 34 |
|
25 | | -run.__doc__ = _pyprofile.run.__doc__ |
26 | | -runctx.__doc__ = _pyprofile.runctx.__doc__ |
| 35 | + statement and filename have the same semantics as profile.run |
| 36 | + """ |
| 37 | + return _Utils(Profile).runctx(statement, globals, locals, |
| 38 | + filename, sort) |
27 | 39 |
|
28 | 40 | # ____________________________________________________________ |
29 | 41 |
|
|
0 commit comments