diff options
author | Nicholas Bastin <nick.bastin@gmail.com> | 2004-03-24 21:57:10 (GMT) |
---|---|---|
committer | Nicholas Bastin <nick.bastin@gmail.com> | 2004-03-24 21:57:10 (GMT) |
commit | c69ebe8d50529eae281275c841428eb9b375a442 (patch) | |
tree | b8150da59983ca89c192b45311eeee050a0b4a16 /Lib/test | |
parent | a1dde13389cf47ac626394796740925504e3e272 (diff) | |
download | cpython-c69ebe8d50529eae281275c841428eb9b375a442.zip cpython-c69ebe8d50529eae281275c841428eb9b375a442.tar.gz cpython-c69ebe8d50529eae281275c841428eb9b375a442.tar.bz2 |
Enable the profiling of C functions (builtins and extensions)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/output/test_profile | 5 | ||||
-rw-r--r-- | Lib/test/test_profilehooks.py | 11 |
2 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/output/test_profile b/Lib/test/output/test_profile index 917a18e..b46bb6a 100644 --- a/Lib/test/output/test_profile +++ b/Lib/test/output/test_profile @@ -1,9 +1,12 @@ test_profile - 53 function calls in 1.000 CPU seconds + 74 function calls in 1.000 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) + 12 0.000 0.000 0.012 0.001 :0(hasattr) + 8 0.000 0.000 0.000 0.000 :0(range) + 1 0.000 0.000 0.000 0.000 :0(setprofile) 1 0.000 0.000 1.000 1.000 <string>:1(?) 0 0.000 0.000 profile:0(profiler) 1 0.000 0.000 1.000 1.000 profile:0(testfunc()) diff --git a/Lib/test/test_profilehooks.py b/Lib/test/test_profilehooks.py index ac8ebd8..53f882a 100644 --- a/Lib/test/test_profilehooks.py +++ b/Lib/test/test_profilehooks.py @@ -11,7 +11,10 @@ class HookWatcher: self.events = [] def callback(self, frame, event, arg): - self.add_event(event, frame) + if (event == "call" + or event == "return" + or event == "exception"): + self.add_event(event, frame) def add_event(self, event, frame=None): """Add an event to the log.""" @@ -56,10 +59,16 @@ class ProfileSimulator(HookWatcher): self.testcase.fail( "the profiler should never receive exception events") + def trace_pass(self, frame): + pass + dispatch = { 'call': trace_call, 'exception': trace_exception, 'return': trace_return, + 'c_call': trace_pass, + 'c_return': trace_pass, + 'c_exception': trace_pass, } |