home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / pyhtmldoc / d / determinis < prev    next >
Encoding:
Text File  |  1996-11-14  |  2.1 KB  |  36 lines

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