bpo-32512: Add -m option to profile for profiling modules (#5132)

The new option in the CLI of the profile module allow to profile
executable modules. This change follows the same implementation as the
one already present in `cProfile`.

As the argument is now present on both modules, move the tests to the
common test case to be run with profile as well.
This commit is contained in:
Mario Corchero 2018-11-05 15:03:46 +03:00 committed by Nick Coghlan
parent 2810dd7be9
commit ad1a25f499
5 changed files with 42 additions and 27 deletions

View file

@ -120,8 +120,8 @@ results to a file by specifying a filename to the :func:`run` function::
The :class:`pstats.Stats` class reads profile results from a file and formats
them in various ways.
The file :mod:`cProfile` can also be invoked as a script to profile another
script. For example::
The files :mod:`cProfile` and :mod:`profile` can also be invoked as a script to
profile another script. For example::
python -m cProfile [-o output_file] [-s sort_order] (-m module | myscript.py)
@ -133,7 +133,10 @@ the output by. This only applies when ``-o`` is not supplied.
``-m`` specifies that a module is being profiled instead of a script.
.. versionadded:: 3.7
Added the ``-m`` option.
Added the ``-m`` option to :mod:`cProfile`.
.. versionadded:: 3.8
Added the ``-m`` option to :mod:`profile`.
The :mod:`pstats` module's :class:`~pstats.Stats` class has a variety of methods
for manipulating and printing the data saved into a profile results file::