Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
cProfile.Profile Class Reference

List of all members.

Public Member Functions

def print_stats
def dump_stats
def create_stats
def snapshot_stats
def run
def runctx
def runcall

Public Attributes

 stats

Detailed Description

Profile(custom_timer=None, time_unit=None, subcalls=True, builtins=True)

Builds a profiler object using the specified timer function.
The default timer is a fast built-in one based on real time.
For custom timer functions returning integers, time_unit can
be a float specifying a scale (i.e. how long each integer unit
is, in seconds).

Definition at line 61 of file cProfile.py.


Member Function Documentation

Definition at line 85 of file cProfile.py.

00085 
00086     def create_stats(self):
00087         self.disable()
00088         self.snapshot_stats()

Here is the call graph for this function:

Here is the caller graph for this function:

def cProfile.Profile.dump_stats (   self,
  file 
)

Definition at line 78 of file cProfile.py.

00078 
00079     def dump_stats(self, file):
00080         import marshal
00081         f = open(file, 'wb')
00082         self.create_stats()
00083         marshal.dump(self.stats, f)
00084         f.close()

Here is the call graph for this function:

def cProfile.Profile.print_stats (   self,
  sort = -1 
)

Definition at line 74 of file cProfile.py.

00074 
00075     def print_stats(self, sort=-1):
00076         import pstats
00077         pstats.Stats(self).strip_dirs().sort_stats(sort).print_stats()

def cProfile.Profile.run (   self,
  cmd 
)

Definition at line 127 of file cProfile.py.

00127 
00128     def run(self, cmd):
00129         import __main__
00130         dict = __main__.__dict__
00131         return self.runctx(cmd, dict, dict)

Here is the call graph for this function:

Here is the caller graph for this function:

def cProfile.Profile.runcall (   self,
  func,
  args,
  kw 
)

Definition at line 141 of file cProfile.py.

00141 
00142     def runcall(self, func, *args, **kw):
00143         self.enable()
00144         try:
00145             return func(*args, **kw)
00146         finally:
00147             self.disable()
00148 
00149 # ____________________________________________________________

Here is the call graph for this function:

def cProfile.Profile.runctx (   self,
  cmd,
  globals,
  locals 
)

Definition at line 132 of file cProfile.py.

00132 
00133     def runctx(self, cmd, globals, locals):
00134         self.enable()
00135         try:
00136             exec(cmd, globals, locals)
00137         finally:
00138             self.disable()
00139         return self

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 89 of file cProfile.py.

00089 
00090     def snapshot_stats(self):
00091         entries = self.getstats()
00092         self.stats = {}
00093         callersdicts = {}
00094         # call information
00095         for entry in entries:
00096             func = label(entry.code)
00097             nc = entry.callcount         # ncalls column of pstats (before '/')
00098             cc = nc - entry.reccallcount # ncalls column of pstats (after '/')
00099             tt = entry.inlinetime        # tottime column of pstats
00100             ct = entry.totaltime         # cumtime column of pstats
00101             callers = {}
00102             callersdicts[id(entry.code)] = callers
00103             self.stats[func] = cc, nc, tt, ct, callers
00104         # subcall information
00105         for entry in entries:
00106             if entry.calls:
00107                 func = label(entry.code)
00108                 for subentry in entry.calls:
00109                     try:
00110                         callers = callersdicts[id(subentry.code)]
00111                     except KeyError:
00112                         continue
00113                     nc = subentry.callcount
00114                     cc = nc - subentry.reccallcount
00115                     tt = subentry.inlinetime
00116                     ct = subentry.totaltime
00117                     if func in callers:
00118                         prev = callers[func]
00119                         nc += prev[0]
00120                         cc += prev[1]
00121                         tt += prev[2]
00122                         ct += prev[3]
00123                     callers[func] = nc, cc, tt, ct

Here is the caller graph for this function:


Member Data Documentation

Definition at line 91 of file cProfile.py.


The documentation for this class was generated from the following file: