summaryrefslogtreecommitdiffstats
path: root/Lib/profile.py
diff options
context:
space:
mode:
authorSjoerd Mullender <sjoerd@acm.org>1993-08-25 14:09:01 (GMT)
committerSjoerd Mullender <sjoerd@acm.org>1993-08-25 14:09:01 (GMT)
commit4fddf33c87e8a377e98b8d05eb5a9808986081c2 (patch)
tree719fb0c4c3d7fe0bafeb6d2b31a96d678d20aa55 /Lib/profile.py
parentf64992e95d3b87799d4a423d2d0c0047b177c56b (diff)
downloadcpython-4fddf33c87e8a377e98b8d05eb5a9808986081c2.zip
cpython-4fddf33c87e8a377e98b8d05eb5a9808986081c2.tar.gz
cpython-4fddf33c87e8a377e98b8d05eb5a9808986081c2.tar.bz2
XEvent.py: Added support for ExposeEvent.
profile.py: Some speed improvements (I hope). rect.py: Bug fix in union().
Diffstat (limited to 'Lib/profile.py')
-rwxr-xr-xLib/profile.py49
1 files changed, 33 insertions, 16 deletions
diff --git a/Lib/profile.py b/Lib/profile.py
index a965f95..000e79a 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -36,20 +36,29 @@ class Profile:
self.profiling = 1
t = os.times()
t = t[0] + t[1]
- lineno = codehack.getlineno(frame.f_code)
- filename = frame.f_code.co_filename
- key = filename + ':' + `lineno` + '(' + funcname + ')'
+ if frame.f_locals.has_key('__key'):
+ key = frame.f_locals['__key']
+ else:
+ lineno = codehack.getlineno(frame.f_code)
+ filename = frame.f_code.co_filename
+ key = filename + ':' + `lineno` + '(' + funcname + ')'
+ frame.f_locals['__key'] = key
self.call_level = depth(frame)
self.cur_frame = frame
pframe = frame.f_back
if self.debug:
s0 = 'call: ' + key + ' depth: ' + `self.call_level` + ' time: ' + `t`
if pframe:
- pkey = pframe.f_code.co_filename + ':' + \
- `codehack.getlineno(pframe.f_code)` \
- + '(' + \
- codehack.getcodename(pframe.f_code) \
- + ')'
+ if pframe.f_locals.has_key('__key'):
+ pkey = pframe.f_locals['__key']
+ else:
+ pkey = pframe.f_code.co_filename + \
+ ':' + \
+ `codehack.getlineno(pframe.f_code)` \
+ + '(' + \
+ codehack.getcodename(pframe.f_code) \
+ + ')'
+ pframe.f_locals['__key'] = pkey
if self.debug:
s1 = 'parent: ' + pkey
if pframe.f_locals.has_key('__start_time'):
@@ -121,17 +130,25 @@ class Profile:
def handle_return(self, pframe, frame, s0):
t = os.times()
t = t[0] + t[1]
- funcname = codehack.getcodename(frame.f_code)
- lineno = codehack.getlineno(frame.f_code)
- filename = frame.f_code.co_filename
- key = filename + ':' + `lineno` + '(' + funcname + ')'
- if self.debug:
- s0 = s0 + key + ' depth: ' + `self.call_level` + ' time: ' + `t`
- if pframe:
+ if frame.f_locals.has_key('__key'):
+ key = frame.f_locals['__key']
+ else:
funcname = codehack.getcodename(frame.f_code)
lineno = codehack.getlineno(frame.f_code)
filename = frame.f_code.co_filename
- pkey = filename + ':' + `lineno` + '(' + funcname + ')'
+ key = filename + ':' + `lineno` + '(' + funcname + ')'
+ frame.f_locals['__key'] = key
+ if self.debug:
+ s0 = s0 + key + ' depth: ' + `self.call_level` + ' time: ' + `t`
+ if pframe:
+ if pframe.f_locals.has_key('__key'):
+ pkey = pframe.f_locals['__key']
+ else:
+ funcname = codehack.getcodename(frame.f_code)
+ lineno = codehack.getlineno(frame.f_code)
+ filename = frame.f_code.co_filename
+ pkey = filename + ':' + `lineno` + '(' + funcname + ')'
+ pframe.f_locals['__key'] = pkey
if self.debug:
s1 = 'parent: '+pkey
if pframe.f_locals.has_key('__start_time') and \