%load_ext pyinstrument
│ │ │ ├── html2text {}
│ │ │ │ @@ -16,74 +16,37 @@
│ │ │ │ Pyinstrument supports Python 3.8+.
│ │ │ │ ********** PPrrooffiillee aa PPyytthhoonn ssccrriipptt_?¶ **********
│ │ │ │ Call Pyinstrument directly from the command line. Instead of writing python3
│ │ │ │ script.py, type pyinstrument script.py. Your script will run as normal, and at
│ │ │ │ the end (or when you press ^C), Pyinstrument will output a colored summary
│ │ │ │ showing where most of the time was spent.
│ │ │ │ Here are the options you can use:
│ │ │ │ -Usage: pyinstrument [options] scriptfile [arg] ...
│ │ │ │ -
│ │ │ │ -Options:
│ │ │ │ - --version show program's version number and exit
│ │ │ │ - -h, --help show this help message and exit
│ │ │ │ - --load=FILENAME instead of running a script, load a profile session
│ │ │ │ - from a pyisession file
│ │ │ │ - --load-prev=IDENTIFIER
│ │ │ │ - instead of running a script, load a previous profile
│ │ │ │ - session as specified by an identifier
│ │ │ │ - -m MODULE run library module as a script, like 'python -m
│ │ │ │ - module'
│ │ │ │ - -c PROGRAM program passed in as string, like 'python -c "..."'
│ │ │ │ - --from-path (POSIX only) instead of the working directory, look
│ │ │ │ - for scriptfile in the PATH environment variable
│ │ │ │ - -o OUTFILE, --outfile=OUTFILE
│ │ │ │ - save to
│ │ │ │ - -r RENDERER, --renderer=RENDERER
│ │ │ │ - how the report should be rendered. One of: 'text',
│ │ │ │ - 'html', 'json', 'speedscope', 'pyisession', 'pstats',
│ │ │ │ - or python import path to a renderer class. Defaults to
│ │ │ │ - the appropriate format for the extension if OUTFILE is
│ │ │ │ - given, otherwise, defaults to 'text'.
│ │ │ │ - -p RENDER_OPTION, --render-option=RENDER_OPTION
│ │ │ │ - options to pass to the renderer, in the format
│ │ │ │ - 'flag_name' or 'option_name=option_value'. For
│ │ │ │ - example, to set the option 'time', pass '-p
│ │ │ │ - time=percent_of_total'. To pass multiple options, use
│ │ │ │ - the -p option multiple times. You can set processor
│ │ │ │ - options using dot-syntax, like '-p
│ │ │ │ - processor_options.filter_threshold=0'. option_value is
│ │ │ │ - parsed as a JSON value or a string.
│ │ │ │ - -t, --timeline render as a timeline - preserve ordering and don't
│ │ │ │ - condense repeated calls
│ │ │ │ - --hide=EXPR glob-style pattern matching the file paths whose
│ │ │ │ - frames to hide. Defaults to hiding non-application
│ │ │ │ - code
│ │ │ │ - --hide-regex=REGEX regex matching the file paths whose frames to hide.
│ │ │ │ - Useful if --hide doesn't give enough control.
│ │ │ │ - --show=EXPR glob-style pattern matching the file paths whose
│ │ │ │ - frames to show, regardless of --hide or --hide-regex.
│ │ │ │ - For example, use --show '*//*' to show frames
│ │ │ │ - within a library that would otherwise be hidden.
│ │ │ │ - --show-regex=REGEX regex matching the file paths whose frames to always
│ │ │ │ - show. Useful if --show doesn't give enough control.
│ │ │ │ - --show-all show everything
│ │ │ │ - --unicode (text renderer only) force unicode text output
│ │ │ │ - --no-unicode (text renderer only) force ascii text output
│ │ │ │ - --color (text renderer only) force ansi color text output
│ │ │ │ - --no-color (text renderer only) force no color text output
│ │ │ │ - -i INTERVAL, --interval=INTERVAL
│ │ │ │ - Minimum time, in seconds, between each stack sample.
│ │ │ │ - Smaller values allow resolving shorter duration
│ │ │ │ - function calls but incur a greater runtime and memory
│ │ │ │ - consumption overhead. For longer running scripts,
│ │ │ │ - setting a larger interval reduces the memory
│ │ │ │ - consumption required to store the stack samples.
│ │ │ │ - --use-timing-thread Use a separate thread to time the interval between
│ │ │ │ - stack samples. This can reduce the overhead of
│ │ │ │ - sampling on some systems.
│ │ │ │ +Traceback (most recent call last):
│ │ │ │ + File "", line 189, in _run_module_as_main
│ │ │ │ + File "", line 148, in _get_module_details
│ │ │ │ + File "", line 112, in _get_module_details
│ │ │ │ + File "/build/reproducible-path/python-pyinstrument-5.1.1+ds/.pybuild/
│ │ │ │ +cpython3_3.14_pyinstrument/build/pyinstrument/__init__.py", line 3, in
│ │ │ │ + from pyinstrument.context_manager import profile
│ │ │ │ + File "/build/reproducible-path/python-pyinstrument-5.1.1+ds/.pybuild/
│ │ │ │ +cpython3_3.14_pyinstrument/build/pyinstrument/context_manager.py", line 8, in
│ │ │ │ +
│ │ │ │ + from pyinstrument.profiler import AsyncMode, Profiler
│ │ │ │ + File "/build/reproducible-path/python-pyinstrument-5.1.1+ds/.pybuild/
│ │ │ │ +cpython3_3.14_pyinstrument/build/pyinstrument/profiler.py", line 16, in
│ │ │ │ +
│ │ │ │ + from pyinstrument.stack_sampler import AsyncState, StackSampler,
│ │ │ │ +build_call_stack, get_stack_sampler
│ │ │ │ + File "/build/reproducible-path/python-pyinstrument-5.1.1+ds/.pybuild/
│ │ │ │ +cpython3_3.14_pyinstrument/build/pyinstrument/stack_sampler.py", line 12, in
│ │ │ │ +
│ │ │ │ + from pyinstrument.low_level.stat_profile import (
│ │ │ │ + ...<4 lines>...
│ │ │ │ + )
│ │ │ │ +ModuleNotFoundError: No module named 'pyinstrument.low_level.stat_profile'
│ │ │ │ PPrroottiipp:: -r html will give you a interactive profile report as HTML - you can
│ │ │ │ really explore this way!
│ │ │ │ ********** PPrrooffiillee aa PPyytthhoonn CCLLII ccoommmmaanndd_?¶ **********
│ │ │ │ For profiling an installed Python script via the _“_c_o_n_s_o_l_e___s_c_r_i_p_t_”_ _e_n_t_r_y_ _p_o_i_n_t,
│ │ │ │ call Pyinstrument directly from the command line with the --from-path flag.
│ │ │ │ Instead of writing cli-script, type pyinstrument --from-path cli-script. Your
│ │ │ │ script will run as normal, and at the end (or when you press ^C), Pyinstrument
│ │ │ │ @@ -115,16 +78,16 @@
│ │ │ │ than the default 0.001 (1 millisecond) like this:
│ │ │ │ pyinstrument.profile(interval=0.0001)
│ │ │ │ # or,
│ │ │ │ profiler = Profiler(interval=0.0001)
│ │ │ │ ...
│ │ │ │ Experiment with the interval value to see different depths, but keep in mind
│ │ │ │ that smaller intervals could affect the performance overhead of profiling.
│ │ │ │ -PPrroottiipp:: To explore the profile in a web browser, use _p_r_o_f_i_l_e_r_._o_p_e_n___i_n___b_r_o_w_s_e_r
│ │ │ │ -_(_). To save this HTML for later, use _p_r_o_f_i_l_e_r_._o_u_t_p_u_t___h_t_m_l_(_).
│ │ │ │ +PPrroottiipp:: To explore the profile in a web browser, use profiler.open_in_browser
│ │ │ │ +(). To save this HTML for later, use profiler.output_html().
│ │ │ │ ********** PPrrooffiillee ccooddee iinn JJuuppyytteerr//IIPPyytthhoonn_?¶ **********
│ │ │ │ Via _I_P_y_t_h_o_n_ _m_a_g_i_c_s, you can profile a line or a cell in IPython or Jupyter.
│ │ │ │ Example:
│ │ │ │ %load_ext pyinstrument
│ │ │ │ %%pyinstrument
│ │ │ │ import time
│ │ ├── ./usr/share/doc/python-pyinstrument-doc/html/how-it-works.html
│ │ │ @@ -348,15 +348,15 @@
│ │ │ be in your program, but you should still be able to find why it’s slow.
│ │ │
│ │ │
│ │ │ Async profiling
│ │ │ pyinstrument can profile async programs that use async and await. This
│ │ │ async support works by tracking the ‘context’ of execution, as provided by the
│ │ │ built-in contextvars module.
│ │ │ -When you start a Profiler with the async_mode enabled or strict (not disabled), that Profiler is attached to the current async context.
│ │ │ +When you start a Profiler with the async_mode enabled or strict (not disabled), that Profiler is attached to the current async context.
│ │ │ When profiling, pyinstrument keeps an eye on the context. When execution exits
│ │ │ the context, it captures the await stack that caused the context to exit.
│ │ │ Any time spent outside the context is attributed to the that halted execution
│ │ │ of the await.
│ │ │ Async contexts are inherited, so tasks started when a profiler is active are
│ │ │ also profiled.
│ │ │
│ │ │ ├── html2text {}
│ │ │ │ @@ -86,15 +86,15 @@
│ │ │ │ That’s really important when debugging performance problems, since Python is
│ │ │ │ often used as a ‘glue’ language between other services. The problem might not
│ │ │ │ be in your program, but you should still be able to find why it’s slow.
│ │ │ │ ********** AAssyynncc pprrooffiilliinngg_?¶ **********
│ │ │ │ pyinstrument can profile async programs that use async and await. This async
│ │ │ │ support works by tracking the ‘context’ of execution, as provided by the built-
│ │ │ │ in _c_o_n_t_e_x_t_v_a_r_s module.
│ │ │ │ -When you start a Profiler with the _a_s_y_n_c___m_o_d_e enabled or strict (not disabled),
│ │ │ │ +When you start a Profiler with the async_mode enabled or strict (not disabled),
│ │ │ │ that Profiler is attached to the current async context.
│ │ │ │ When profiling, pyinstrument keeps an eye on the context. When execution exits
│ │ │ │ the context, it captures the await stack that caused the context to exit. Any
│ │ │ │ time spent outside the context is attributed to the that halted execution of
│ │ │ │ the await.
│ │ │ │ Async contexts are inherited, so tasks started when a profiler is active are
│ │ │ │ also profiled.
│ │ ├── ./usr/share/doc/python-pyinstrument-doc/html/objects.inv
│ │ │ ├── Sphinx inventory
│ │ │ │ @@ -1,38 +1,22 @@
│ │ │ │ # Sphinx inventory version 2
│ │ │ │ # Project: pyinstrument
│ │ │ │ # Version:
│ │ │ │ # The remainder of this file is compressed using zlib.
│ │ │ │
│ │ │ │ -pyinstrument.Profiler py:class 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.__enter__ py:method 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.async_mode py:property 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.interval py:property 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.is_running py:property 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.last_session py:property 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.open_in_browser py:method 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.output py:method 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.output_html py:method 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.output_text py:method 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.print py:method 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.reset py:method 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.start py:method 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.stop py:method 1 reference.html#$ -
│ │ │ │ -pyinstrument.Profiler.write_html py:method 1 reference.html#$ -
│ │ │ │ pyinstrument.processors py:module 0 reference.html#module-$ -
│ │ │ │ pyinstrument.processors.aggregate_repeated_calls py:function 1 reference.html#$ -
│ │ │ │ pyinstrument.processors.group_library_frames_processor py:function 1 reference.html#$ -
│ │ │ │ pyinstrument.processors.merge_consecutive_self_time py:function 1 reference.html#$ -
│ │ │ │ pyinstrument.processors.remove_first_pyinstrument_frames_processor py:function 1 reference.html#$ -
│ │ │ │ pyinstrument.processors.remove_importlib py:function 1 reference.html#$ -
│ │ │ │ pyinstrument.processors.remove_irrelevant_nodes py:function 1 reference.html#$ -
│ │ │ │ pyinstrument.processors.remove_tracebackhide py:function 1 reference.html#$ -
│ │ │ │ pyinstrument.processors.remove_unnecessary_self_time_nodes py:function 1 reference.html#$ -
│ │ │ │ pyinstrument.profile py:function 1 reference.html#$ -
│ │ │ │ -pyinstrument.profiler.Profiler py:class -1 reference.html#pyinstrument.Profiler -
│ │ │ │ pyinstrument.renderers.ConsoleRenderer py:class 1 reference.html#$ -
│ │ │ │ pyinstrument.renderers.FrameRenderer py:class 1 reference.html#$ -
│ │ │ │ pyinstrument.renderers.FrameRenderer.default_processors py:method 1 reference.html#$ -
│ │ │ │ pyinstrument.renderers.FrameRenderer.processor_options py:attribute 1 reference.html#$ -
│ │ │ │ pyinstrument.renderers.FrameRenderer.processors py:attribute 1 reference.html#$ -
│ │ │ │ pyinstrument.renderers.FrameRenderer.render py:method 1 reference.html#$ -
│ │ │ │ pyinstrument.renderers.HTMLRenderer py:class 1 reference.html#$ -
│ │ ├── ./usr/share/doc/python-pyinstrument-doc/html/reference.html
│ │ │ @@ -334,194 +334,21 @@
│ │ │ time.sleep(1)
│ │ │