IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
25.1 Introduction to the profilers

25.1 Introduction to the profilers

A profiler is a program that describes the run time performance of a program, providing a variety of statistics. This documentation describes the profiler functionality provided in the modules profile and pstats. This profiler provides deterministic profiling of any Python programs. It also provides a series of report generation tools to allow users to rapidly examine the results of a profile operation.

The Python standard library provides three different profilers:

  1. profile, a pure Python module, described in the sequel. Copyright © 1994, by InfoSeek Corporation. Changed in version 2.4: also reports the time spent in calls to built-in functions and methods.

  2. cProfile, a module written in C, with a reasonable overhead that makes it suitable for profiling long-running programs. Based on lsprof, contributed by Brett Rosen and Ted Czotter. New in version 2.5.

  3. hotshot, a C module focusing on minimizing the overhead while profiling, at the expense of long data post-processing times. Changed in version 2.5: the results should be more meaningful than in the past: the timing core contained a critical bug.

The profile and cProfile modules export the same interface, so they are mostly interchangeables; cProfile has a much lower overhead but is not so far as well-tested and might not be available on all systems. cProfile is really a compatibility layer on top of the internal _lsprof module. The hotshot module is reserved to specialized usages.

See About this document... for information on suggesting changes.