Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/spst/UnixTransition/doc/profile.html
Дата изменения: Thu Nov 5 13:46:17 2015
Дата индексирования: Sun Apr 10 21:30:15 2016
Кодировка:

Поисковые слова: п п п п п п п п п п п п п п
Python: module profile
 
 
profile
index
/usr/local/Python-2.5/lib/python2.5/profile.py
Module Docs

Class for profiling Python code.

 
Modules
       
marshal
os
resource
sys
time

 
Classes
       
Profile

 
class Profile
    Profiler class.
 
self.cur is always a tuple.  Each such tuple corresponds to a stack
frame that is currently active (self.cur[-2]).  The following are the
definitions of its members.  We use this external "parallel stack" to
avoid contaminating the program that we are profiling. (old profiler
used to write into the frames local dictionary!!) Derived classes
can change the definition of some entries, as long as they leave
[-2:] intact (frame and previous tuple).  In case an internal error is
detected, the -3 element is used as the function name.
 
[ 0] = Time that needs to be charged to the parent frame's function.
       It is used so that a function call will not have to access the
       timing data for the parent frame.
[ 1] = Total time spent in this frame's function, excluding time in
       subfunctions (this latter is tallied in cur[2]).
[ 2] = Total time spent in subfunctions, excluding time executing the
       frame's function (this latter is tallied in cur[1]).
[-3] = Name of the function that corresponds to this frame.
[-2] = Actual frame that we correspond to (used to sync exception handling).
[-1] = Our parent 6-tuple (corresponds to frame.f_back).
 
Timing data for each function is stored as a 5-tuple in the dictionary
self.timings[].  The index is always the name stored in self.cur[-3].
The following are the definitions of the members:
 
[0] = The number of times this function was called, not counting direct
      or indirect recursion,
[1] = Number of times this function appears on the stack, minus one
[2] = Total time spent internal to this function
[3] = Cumulative time that this function was present on the stack.  In
      non-recursive functions, this is the total execution time from start
      to finish of each invocation of a function, including time spent in
      all subfunctions.
[4] = A dictionary indicating for each function name, the number of times
      it was called by us.
 
  Methods defined here:
__init__(self, timer=None, bias=None)
calibrate(self, m, verbose=0)
create_stats(self)
dump_stats(self, file)
print_stats(self, sort=-1)
run(self, cmd)
runcall(self, func, *args, **kw)
# This method is more useful to profile a single function call.
runctx(self, cmd, globals, locals)
set_cmd(self, cmd)
simulate_call(self, name)
simulate_cmd_complete(self)
snapshot_stats(self)
trace_dispatch(self, frame, event, arg)
trace_dispatch_c_call(self, frame, t)
trace_dispatch_call(self, frame, t)
trace_dispatch_exception(self, frame, t)
trace_dispatch_i(self, frame, event, arg)
trace_dispatch_l(self, frame, event, arg)
trace_dispatch_mac(self, frame, event, arg)
trace_dispatch_return(self, frame, t)

Data and other attributes defined here:
bias = 0
dispatch = {'c_call': <function trace_dispatch_c_call at 0x18def330>, 'c_exception': <function trace_dispatch_return at 0x18def370>, 'c_return': <function trace_dispatch_return at 0x18def370>, 'call': <function trace_dispatch_call at 0x18def2f0>, 'exception': <function trace_dispatch_exception at 0x18def2b0>, 'return': <function trace_dispatch_return at 0x18def370>}
fake_code = <class profile.fake_code at 0x18dec2d0>
fake_frame = <class profile.fake_frame at 0x18dec300>

 
Functions
       
help()
# Backwards compatibility.
run(statement, filename=None, sort=-1)
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.
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

 
Data
        __all__ = ['run', 'runctx', 'help', 'Profile']