10.6 Limitations
There are two fundamental limitations on this profiler. The first is that it relies on the
Python interpreter to dispatch call, return, and exception events. Compiled C code does not get interpreted, and hence is
``invisible'' to the profiler. All time spent in C code (including built-in functions) will be
charged to the Python function that invoked the C code. If the C code calls out to some native
Python code, then those calls will be profiled properly.
The second limitation has to do with accuracy of timing information. There is a fundamental
problem with deterministic profilers involving accuracy. The most obvious restriction is that
the underlying ``clock'' is only ticking at a rate (typically) of about .001 seconds. Hence no
measurements will be more accurate than the underlying clock. If enough measurements are
taken, then the ``error'' will tend to average out. Unfortunately, removing this first error
induces a second source of error...
The second problem is that it ``takes a while'' from when an event is dispatched until the
profiler's call to get the time actually gets the state of the clock. Similarly, there
is a certain lag when exiting the profiler event handler from the time that the clock's value
was obtained (and then squirreled away), until the user's code is once again executing. As a
result, functions that are called many times, or call many functions, will typically
accumulate this error. The error that accumulates in this fashion is typically less than the
accuracy of the clock (less than one clock tick), but it can accumulate and become very
significant. This profiler provides a means of calibrating itself for a given platform so that
this error can be probabilistically (on the average) removed. After the profiler is
calibrated, it will be more accurate (in a least square sense), but it will sometimes produce
negative numbers (when call counts are exceptionally low, and the gods of probability work
against you :-). ) Do not be alarmed by negative numbers in the profile. They should only
appear if you have calibrated your profiler, and the results are actually better than without
calibration.
|