home *** CD-ROM | disk | FTP | other *** search
- <TITLE>Deterministic Profiling -- Python library reference</TITLE>
- Next: <A HREF="../r/reference_manual" TYPE="Next">Reference Manual</A>
- Prev: <A HREF="../i/instant_users_manual" TYPE="Prev">Instant Users Manual</A>
- Up: <A HREF="../t/the_python_profiler" TYPE="Up">The Python Profiler</A>
- Top: <A HREF="../t/top" TYPE="Top">Top</A>
- <H1>9.4. What Is Deterministic Profiling?</H1>
- <DFN>Deterministic profiling</DFN> is meant to reflect the fact that all
- <DFN>function call</DFN>, <DFN>function return</DFN>, and <DFN>exception</DFN> events
- are monitored, and precise timings are made for the intervals between
- these events (during which time the user's code is executing). In
- contrast, <DFN>statistical profiling</DFN> (which is not done by this
- module) randomly samples the effective instruction pointer, and
- deduces where time is being spent. The latter technique traditionally
- involves less overhead (as the code does not need to be instrumented),
- but provides only relative indications of where time is being spent.
- <P>
- In Python, since there is an interpreter active during execution, the
- presence of instrumented code is not required to do deterministic
- profiling. Python automatically provides a <DFN>hook</DFN> (optional
- callback) for each event. In addition, the interpreted nature of
- Python tends to add so much overhead to execution, that deterministic
- profiling tends to only add small processing overhead in typical
- applications. The result is that deterministic profiling is not that
- expensive, yet provides extensive run time statistics about the
- execution of a Python program.
- <P>
- Call count statistics can be used to identify bugs in code (surprising
- counts), and to identify possible inline-expansion points (high call
- counts). Internal time statistics can be used to identify ``hot
- loops'' that should be carefully optimized. Cumulative time
- statistics should be used to identify high level errors in the
- selection of algorithms. Note that the unusual handling of cumulative
- times in this profiler allows statistics for recursive implementations
- of algorithms to be directly compared to iterative implementations.
- <P>
-