[Python-checkins]
python/dist/src/Lib bdb.py, 1.43, 1.44 profile.py, 1.54, 1.55
mondragon at users.sourceforge.net
mondragon at users.sourceforge.net
Wed Mar 24 16:57:10 EST 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8622/Lib
Modified Files:
bdb.py profile.py
Log Message:
Enable the profiling of C functions (builtins and extensions)
Index: bdb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bdb.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** bdb.py 12 Feb 2004 17:35:05 -0000 1.43
--- bdb.py 24 Mar 2004 21:57:08 -0000 1.44
***************
*** 53,56 ****
--- 53,62 ----
if event == 'exception':
return self.dispatch_exception(frame, arg)
+ if event == 'c_call':
+ return self.trace_dispatch
+ if event == 'c_exception':
+ return self.trace_dispatch
+ if event == 'c_return':
+ return self.trace_dispatch
print 'bdb.Bdb.dispatch: unknown debugging event:', repr(event)
return self.trace_dispatch
Index: profile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** profile.py 23 Mar 2004 19:19:21 -0000 1.54
--- profile.py 24 Mar 2004 21:57:08 -0000 1.55
***************
*** 164,167 ****
--- 164,168 ----
self.cur = None
self.cmd = ""
+ self.c_func_name = ""
if bias is None:
***************
*** 215,218 ****
--- 216,222 ----
t = t[0] + t[1] - self.t - self.bias
+ if event == "c_call":
+ self.c_func_name = arg
+
if self.dispatch[event](self, frame,t):
t = timer()
***************
*** 228,232 ****
timer = self.timer
t = timer() - self.t - self.bias
! if self.dispatch[event](self, frame,t):
self.t = timer()
else:
--- 232,240 ----
timer = self.timer
t = timer() - self.t - self.bias
!
! if event == "c_call":
! self.c_func_name = arg
!
! if self.dispatch[event](self, frame, t):
self.t = timer()
else:
***************
*** 239,242 ****
--- 247,254 ----
timer = self.timer
t = timer()/60.0 - self.t - self.bias
+
+ if event == "c_call":
+ self.c_func_name = arg
+
if self.dispatch[event](self, frame, t):
self.t = timer()/60.0
***************
*** 250,253 ****
--- 262,268 ----
t = get_time() - self.t - self.bias
+ if event == "c_call":
+ self.c_func_name = arg
+
if self.dispatch[event](self, frame, t):
self.t = get_time()
***************
*** 292,295 ****
--- 307,321 ----
return 1
+ def trace_dispatch_c_call (self, frame, t):
+ fn = ("", 0, self.c_func_name)
+ self.cur = (t, 0, 0, fn, frame, self.cur)
+ timings = self.timings
+ if timings.has_key(fn):
+ cc, ns, tt, ct, callers = timings[fn]
+ timings[fn] = cc, ns+1, tt, ct, callers
+ else:
+ timings[fn] = 0, 0, 0, 0, {}
+ return 1
+
def trace_dispatch_return(self, frame, t):
if frame is not self.cur[-2]:
***************
*** 334,337 ****
--- 360,366 ----
"exception": trace_dispatch_exception,
"return": trace_dispatch_return,
+ "c_call": trace_dispatch_c_call,
+ "c_exception": trace_dispatch_exception,
+ "c_return": trace_dispatch_return,
}
More information about the Python-checkins
mailing list