summaryrefslogtreecommitdiffstats
path: root/Lib/test/output/test_profile
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-10-04 00:58:24 (GMT)
committerGuido van Rossum <guido@python.org>2001-10-04 00:58:24 (GMT)
commitf137f75ab82019b7b4db6d45bd69e2c0b155b2eb (patch)
tree263ca955ba5b7350a9eaf4385065eb107322feae /Lib/test/output/test_profile
parent6f3d82693ab9a4b0f4f366f7ead4e50cd8e4934e (diff)
downloadcpython-f137f75ab82019b7b4db6d45bd69e2c0b155b2eb.zip
cpython-f137f75ab82019b7b4db6d45bd69e2c0b155b2eb.tar.gz
cpython-f137f75ab82019b7b4db6d45bd69e2c0b155b2eb.tar.bz2
Hopefully fix the profiler right. Add a test suite that checks that
it deals correctly with some anomalous cases; according to this test suite I've fixed it right. The anomalous cases had to do with 'exception' events: these aren't generated when they would be most helpful, and the profiler has to work hard to recover the right information. The problems occur when C code (such as hasattr(), which is used as the example here) calls back into Python code and clears an exception raised by that Python code. Consider this example: def foo(): hasattr(obj, "bar") Where obj is an instance from a class like this: class C: def __getattr__(self, name): raise AttributeError The profiler sees the following sequence of events: call (foo) call (__getattr__) exception (in __getattr__) return (from foo) Previously, the profiler would assume the return event returned from __getattr__. An if statement checking for this condition and raising an exception was commented out... This version does the right thing.
Diffstat (limited to 'Lib/test/output/test_profile')
-rw-r--r--Lib/test/output/test_profile17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/output/test_profile b/Lib/test/output/test_profile
new file mode 100644
index 0000000..b36a016
--- /dev/null
+++ b/Lib/test/output/test_profile
@@ -0,0 +1,17 @@
+test_profile
+ 53 function calls in 1.000 CPU seconds
+
+ Ordered by: standard name
+
+ ncalls tottime percall cumtime percall filename:lineno(function)
+ 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())
+ 1 0.400 0.400 1.000 1.000 test_profile.py:21(testfunc)
+ 2 0.080 0.040 0.600 0.300 test_profile.py:30(helper)
+ 4 0.116 0.029 0.120 0.030 test_profile.py:48(helper1)
+ 8 0.312 0.039 0.400 0.050 test_profile.py:56(helper2)
+ 8 0.064 0.008 0.080 0.010 test_profile.py:66(subhelper)
+ 28 0.028 0.001 0.028 0.001 test_profile.py:78(__getattr__)
+
+