https://github.com/python/cpython/commit/c19294436242dff8efa912425af9adcda97b1015 commit: c19294436242dff8efa912425af9adcda97b1015 branch: 3.12 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: sobolevn <m...@sobolevn.me> date: 2025-03-01T20:46:45Z summary:
[3.12] gh-130160: use `.. program::` directive for documenting `cProfile` CLI (GH-130314) (#130746) gh-130160: use `.. program::` directive for documenting `cProfile` CLI (GH-130314) (cherry picked from commit 5181ddb29f969c1718f3f4f9618c260807b2886c) Co-authored-by: Apostol Fet <90645107+apostol...@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picn...@users.noreply.github.com> Co-authored-by: Adam Turner <9087854+aa-tur...@users.noreply.github.com> files: M Doc/library/profile.rst diff --git a/Doc/library/profile.rst b/Doc/library/profile.rst index b89655ea472dee..a2887c59283227 100644 --- a/Doc/library/profile.rst +++ b/Doc/library/profile.rst @@ -123,23 +123,32 @@ them in various ways. .. _profile-cli: +.. program:: cProfile + 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) -``-o`` writes the profile results to a file instead of to stdout +.. option:: -o <output_file> + + Writes the profile results to a file instead of to stdout. + +.. option:: -s <sort_order> + + Specifies one of the :func:`~pstats.Stats.sort_stats` sort values + to sort the output by. + This only applies when :option:`-o <cProfile -o>` is not supplied. -``-s`` specifies one of the :func:`~pstats.Stats.sort_stats` sort values to sort -the output by. This only applies when ``-o`` is not supplied. +.. option:: -m <module> -``-m`` specifies that a module is being profiled instead of a script. + Specifies that a module is being profiled instead of a script. -.. versionadded:: 3.7 - Added the ``-m`` option to :mod:`cProfile`. + .. versionadded:: 3.7 + Added the ``-m`` option to :mod:`cProfile`. -.. versionadded:: 3.8 - Added the ``-m`` option to :mod:`profile`. + .. 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:: _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com