Run statement under profiler optionally saving results in filename
This function takes a single argument that can be passed to the
"exec" statement, and an optional file name. In all cases this
routine attempts to "exec" its first argument and gather profiling
statistics from the execution. If no file name is present, then this
function automatically prints a simple profiling report, sorted by the
standard name string (file/line/function-name) that is presented in
each line.
Definition at line 58 of file profile.py.
59 def run(statement, filename=None):
60 """Run statement under profiler optionally saving results in filename
62 This function takes a single argument that can be passed to the
63 "exec" statement, and an optional file name. In all cases this
64 routine attempts to "exec" its first argument and gather profiling
65 statistics from the execution. If no file name is present, then this
66 function automatically prints a simple profiling report, sorted by the
67 standard name string (file/line/function-name) that is presented in
72 prof = prof.run(statement)
75 if filename
is not None:
76 prof.dump_stats(filename)
78 return prof.print_stats()