Lines Matching full:profile
7 **Source code:** :source:`Lib/profile.py` and :source:`Lib/pstats.py`
20 :mod:`cProfile` and :mod:`profile` provide :dfn:`deterministic profiling` of
21 Python programs. A :dfn:`profile` is a set of statistics that describes how
33 2. :mod:`profile`, a pure Python module whose interface is imitated by
40 The profiler modules are designed to provide an execution profile for a given
57 To profile a function that takes a single argument, you can do::
63 (Use :mod:`profile` instead of :mod:`cProfile` if the latter is not available on
66 The above action would run :func:`re.compile` and print profile results like
114 Instead of printing the output at the end of the profile run, you can save the
121 The :class:`pstats.Stats` class reads profile results from a file and formats
124 The files :mod:`cProfile` and :mod:`profile` can also be invoked as a script to
125 profile another script. For example::
129 ``-o`` writes the profile results to a file instead of to stdout
140 Added the ``-m`` option to :mod:`profile`.
143 for manipulating and printing the data saved into a profile results file::
165 This sorts the profile by cumulative time in a function, and then only prints
206 reading and examining profile dumps. It has a simple line-oriented interface
209 :mod:`profile` and :mod:`cProfile` Module Reference
213 .. module:: profile
216 Both the :mod:`profile` and :mod:`cProfile` modules provide the following
242 .. class:: Profile(timer=None, timeunit=0.0, subcalls=True, builtins=True)
254 Directly using the :class:`Profile` class allows formatting profile results
255 without writing the profile data to a file::
259 pr = cProfile.Profile()
269 The :class:`Profile` class can also be used as a context manager (supported
274 with cProfile.Profile() as pr:
293 as the current profile.
298 profile and print the results to stdout.
302 Write the results of the current profile to *filename*.
306 Profile the cmd via :func:`exec`.
310 Profile the cmd via :func:`exec` with the specified global and
315 Profile ``func(*args, **kwargs)``
332 .. class:: Stats(*filenames or profile, stream=sys.stdout)
335 *filename* (or list of filenames) or from a :class:`Profile` instance. Output
339 corresponding version of :mod:`profile` or :mod:`cProfile`. To be specific,
349 Instead of reading the profile data from a file, a :class:`cProfile.Profile`
350 or :class:`profile.Profile` object can be used as the profile data source.
372 to filenames created by the corresponding version of :func:`profile.run`
383 on the :class:`profile.Profile` and :class:`cProfile.Profile` classes.
473 in the :func:`profile.run` definition.
510 * With :mod:`profile`, a number is shown in parentheses after each caller
533 instance holds information related to the function's profile such as how
596 The problem is more important with :mod:`profile` than with the lower-overhead
597 :mod:`cProfile`. For this reason, :mod:`profile` provides a means of
603 the profile. They should *only* appear if you have calibrated your profiler,
612 The profiler of the :mod:`profile` module subtracts a constant from each event
616 :ref:`profile-limitations`). ::
618 import profile
619 pr = profile.Profile()
635 import profile
637 # 1. Apply computed bias to all Profile instances created hereafter.
638 profile.Profile.bias = your_computed_bias
640 # 2. Apply computed bias to a specific Profile instance.
641 pr = profile.Profile()
645 pr = profile.Profile(bias=your_computed_bias)
648 your results will "less often" show up as negative in profile statistics.
657 to the :class:`Profile` class constructor::
659 pr = profile.Profile(your_time_func)
662 you are using :class:`profile.Profile` or :class:`cProfile.Profile`,
665 :class:`profile.Profile`
673 that you choose (see :ref:`profile-calibration`). For most machines, a timer
681 :class:`cProfile.Profile`
686 you would construct the :class:`Profile` instance as follows::
688 pr = cProfile.Profile(your_integer_time_func, 0.001)
690 As the :class:`cProfile.Profile` class cannot be calibrated, custom timer