[Python-checkins] CVS: python/dist/src/Lib profile.py,1.34,1.35

Tim Peters tim_one@users.sourceforge.net
Sat, 06 Oct 2001 20:12:10 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv28021/python/Lib

Modified Files:
	profile.py 
Log Message:
Remove code and docs for the OldProfile and HotProfile classes:  code
hasn't worked in years, docs were wrong, and they aren't interesting
anymore regardless.


Index: profile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** profile.py	2001/10/05 23:15:10	1.34
--- profile.py	2001/10/07 03:12:08	1.35
***************
*** 498,616 ****
          self.ut = t
  
- 
- 
- class OldProfile(Profile):
-     """A derived profiler that simulates the old style profile, providing
-     errant results on recursive functions. The reason for the usefulness of
-     this profiler is that it runs faster (i.e., less overhead).  It still
-     creates all the caller stats, and is quite useful when there is *no*
-     recursion in the user's code.
- 
-     This code also shows how easy it is to create a modified profiler.
-     """
- 
-     def trace_dispatch_exception(self, frame, t):
-         rt, rtt, rct, rfn, rframe, rcur = self.cur
-         if rcur and not rframe is frame:
-             return self.trace_dispatch_return(rframe, t)
-         return 0
- 
-     def trace_dispatch_call(self, frame, t):
-         fn = `frame.f_code`
- 
-         self.cur = (t, 0, 0, fn, frame, self.cur)
-         if self.timings.has_key(fn):
-             tt, ct, callers = self.timings[fn]
-             self.timings[fn] = tt, ct, callers
-         else:
-             self.timings[fn] = 0, 0, {}
-         return 1
- 
-     def trace_dispatch_return(self, frame, t):
-         rt, rtt, rct, rfn, frame, rcur = self.cur
-         rtt = rtt + t
-         sft = rtt + rct
- 
-         pt, ptt, pct, pfn, pframe, pcur = rcur
-         self.cur = pt, ptt+rt, pct+sft, pfn, pframe, pcur
- 
-         tt, ct, callers = self.timings[rfn]
-         if callers.has_key(pfn):
-             callers[pfn] = callers[pfn] + 1
-         else:
-             callers[pfn] = 1
-         self.timings[rfn] = tt+rtt, ct + sft, callers
- 
-         return 1
- 
- 
-     dispatch = {
-         "call": trace_dispatch_call,
-         "exception": trace_dispatch_exception,
-         "return": trace_dispatch_return,
-         }
- 
- 
-     def snapshot_stats(self):
-         self.stats = {}
-         for func in self.timings.keys():
-             tt, ct, callers = self.timings[func]
-             callers = callers.copy()
-             nc = 0
-             for func_caller in callers.keys():
-                 nc = nc + callers[func_caller]
-             self.stats[func] = nc, nc, tt, ct, callers
- 
- 
- 
- class HotProfile(Profile):
-     """The fastest derived profile example.  It does not calculate
-     caller-callee relationships, and does not calculate cumulative
-     time under a function.  It only calculates time spent in a
-     function, so it runs very quickly due to its very low overhead.
-     """
- 
-     def trace_dispatch_exception(self, frame, t):
-         rt, rtt, rfn, rframe, rcur = self.cur
-         if rcur and not rframe is frame:
-             return self.trace_dispatch_return(rframe, t)
-         return 0
- 
-     def trace_dispatch_call(self, frame, t):
-         self.cur = (t, 0, frame, self.cur)
-         return 1
- 
-     def trace_dispatch_return(self, frame, t):
-         rt, rtt, frame, rcur = self.cur
- 
-         rfn = `frame.f_code`
- 
-         pt, ptt, pframe, pcur = rcur
-         self.cur = pt, ptt+rt, pframe, pcur
- 
-         if self.timings.has_key(rfn):
-             nc, tt = self.timings[rfn]
-             self.timings[rfn] = nc + 1, rt + rtt + tt
-         else:
-             self.timings[rfn] =      1, rt + rtt
- 
-         return 1
- 
- 
-     dispatch = {
-         "call": trace_dispatch_call,
-         "exception": trace_dispatch_exception,
-         "return": trace_dispatch_return,
-         }
- 
- 
-     def snapshot_stats(self):
-         self.stats = {}
-         for func in self.timings.keys():
-             nc, tt = self.timings[func]
-             self.stats[func] = nc, nc, tt, 0, {}
- 
- 
- 
  #****************************************************************************
  def Stats(*args):
--- 498,501 ----