Enable the profiling of C functions (builtins and extensions)
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 @@
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 @@
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,
}