vmprof 0.5.0


pip install vmprof

  Latest version

Released: Sep 15, 2026


Meta
Author: vmprof team
Requires Python: <3.16,>=3.9

Classifiers

Programming Language
  • Python
  • Python :: 3
  • Python :: Implementation :: CPython
  • Python :: Implementation :: PyPy

VMProf Python package

Build Status on TravisCI Build Status on TeamCity Read The Docs Build Status on AppVeyor

Head over to https://vmprof.readthedocs.org for more info!

Installation

pip install vmprof
python -m vmprof <your program> <your program args>

Our build system ships wheels to PyPI (Linux, Mac OS X). If you build from source you need to install CPython development headers and libunwind headers (on Linux only). On Windows this means you need Microsoft Visual C++ Compiler for your Python version.

Development

Setting up development can be done using the following commands:

$ virtualenv -p /usr/bin/python3 vmprof3
$ source vmprof3/bin/activate
$ pip install meson-python meson ninja
$ pip install --no-build-isolation --editable .

You need to install python development packages. In case of e.g. Debian or Ubuntu the package you need is python3-dev and libunwind-dev. Now it is time to write a test and implement your feature. If you want your changes to affect vmprof.com, head over to https://github.com/vmprof/vmprof-server and follow the setup instructions.

Consult our section for development at https://vmprof.readthedocs.org for more information.

vmprofshow

vmprofshow is a command line tool that comes with VMProf. It can read profile files and produce a formatted output.

Here is an example of how to use vmprofshow:

Run that smallish program which burns CPU cycles (with vmprof enabled):

$ pypy vmprof/test/cpuburn.py # you can find cpuburn.py in the vmprof-python repo

This will produce a profile file vmprof_cpuburn.dat. Now display the profile using vmprofshow. vmprofshow has multiple modes of showing data. We'll start with the tree-based mode.

Tree-based output

$ vmprofshow vmprof_cpuburn.dat tree

You will see a (colored) output:

$ vmprofshow vmprof_cpuburn.dat tree
100.0%  <module>  100.0%  tests/cpuburn.py:1
100.0% .. test  100.0%  tests/cpuburn.py:35
100.0% .... burn  100.0%  tests/cpuburn.py:26
 99.2% ...... _iterate  99.2%  tests/cpuburn.py:19
 97.7% ........ _iterate  98.5%  tests/cpuburn.py:19
 22.9% .......... _next_rand  23.5%  tests/cpuburn.py:14
 22.9% ............ JIT code  100.0%  0x7fa7dba57a10
 74.7% .......... JIT code  76.4%  0x7fa7dba57a10
  0.1% .......... JIT code  0.1%  0x7fa7dba583b0
  0.5% ........ _next_rand  0.5%  tests/cpuburn.py:14
  0.0% ........ JIT code  0.0%  0x7fa7dba583b0

There is also an option --html to emit the same information as HTML to view in a browser. In this case, the tree branches can be interactively expanded and collapsed.

Line-based output

vmprof supports line profiling mode, which enables collecting and showing the statistics for separate lines inside functions.

To enable collection of lines statistics add --lines argument to vmprof:

$ python -m vmprof --lines -o <output-file> <your program> <your program args>

Or pass lines=True argument to vmprof.enable function, when calling vmprof from code.

To see line statistics for all functions use the lines mode of vmprofshow:

$ vmprofshow <output-file> lines

To see line statistics for a specific function use the --filter argument with the function name:

$ vmprofshow <output-file> lines --filter <function-name>

You will see the result:

$ vmprofshow vmprof_cpuburn.dat lines --filter _next_rand
Total hits: 1170 s
File: tests/cpuburn.py
Function: _next_rand at line 14

Line #     Hits   % Hits  Line Contents
=======================================
    14       38      3.2      def _next_rand(self):
    15                            # http://rosettacode.org/wiki/Linear_congruential_generator
    16      835     71.4          self._rand = (1103515245 * self._rand + 12345) & 0x7fffffff
    17      297     25.4          return self._rand

"Flattened" output

vmprofshow also has a flat mode.

While the tree-based and line-based output styles for vmprofshow give a good view of where time is spent when viewed from the 'root' of the call graph, sometimes it is desirable to get a view from 'leaves' instead. This is particularly helpful when functions exist that get called from multiple places, where each invocation does not consume much time, but all invocations taken together do amount to a substantial cost.

$ vmprofshow vmprof_cpuburn.dat flat                                                                                                                                                                                                                                                                                                                                                                                   andreask_work@dunkel 15:24
    28.895% - _PyFunction_Vectorcall:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/call.c:389
    18.076% - _iterate:cpuburn.py:20
    17.298% - _next_rand:cpuburn.py:15
     5.863% - <native symbol 0x563a5f4eea51>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/longobject.c:3707
     5.831% - PyObject_SetAttr:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/object.c:1031
     4.924% - <native symbol 0x563a5f43fc01>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:787
     4.762% - PyObject_GetAttr:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/object.c:931
     4.373% - <native symbol 0x563a5f457eb1>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:1071
     3.758% - PyNumber_Add:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:957
     3.110% - <native symbol 0x563a5f47c291>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/longobject.c:4848
     1.587% - PyNumber_Multiply:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:988
     1.166% - _PyObject_GetMethod:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/object.c:1139
     0.356% - <native symbol 0x563a5f4ed8f1>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/longobject.c:3432
     0.000% - <native symbol 0x7f0dce8cca80>:-:0
     0.000% - test:cpuburn.py:36
     0.000% - burn:cpuburn.py:27

Sometimes it may be desirable to exclude "native" functions:

$ vmprofshow vmprof_cpuburn.dat flat --no-native                                                                                                                                                                                                                                                                                                                                                                       andreask_work@dunkel 15:27
    53.191% - _next_rand:cpuburn.py:15
    46.809% - _iterate:cpuburn.py:20
     0.000% - test:cpuburn.py:36
     0.000% - burn:cpuburn.py:27

Note that the output represents the time spent in each function, exclusive of functions called. (In --no-native mode, native-code callees remain included in the total.)

Sometimes it may also be desirable to get timings inclusive of called functions:

$ vmprofshow vmprof_cpuburn.dat flat --include-callees                                                                                                                                                                                                                                                                                                                                                                 andreask_work@dunkel 15:31
   100.000% - <native symbol 0x7f0dce8cca80>:-:0
   100.000% - test:cpuburn.py:36
   100.000% - burn:cpuburn.py:27
   100.000% - _iterate:cpuburn.py:20
    53.191% - _next_rand:cpuburn.py:15
    28.895% - _PyFunction_Vectorcall:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/call.c:389
     7.807% - PyNumber_Multiply:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:988
     7.483% - <native symbol 0x563a5f457eb1>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:1071
     6.220% - <native symbol 0x563a5f4eea51>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/longobject.c:3707
     5.831% - PyObject_SetAttr:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/object.c:1031
     4.924% - <native symbol 0x563a5f43fc01>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:787
     4.762% - PyObject_GetAttr:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/object.c:931
     3.758% - PyNumber_Add:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/abstract.c:957
     3.110% - <native symbol 0x563a5f47c291>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/longobject.c:4848
     1.166% - _PyObject_GetMethod:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/object.c:1139
     0.356% - <native symbol 0x563a5f4ed8f1>:/home/conda/feedstock_root/build_artifacts/python-split_1608956461873/work/Objects/longobject.c:3432

This view is quite similar to the "tree" view, minus the nesting.

0.5.0 Sep 15, 2026
0.4.18.1 Sep 29, 2024
0.4.18 Sep 28, 2024
0.4.17 Jan 03, 2024
0.4.15 May 30, 2019
0.4.13 May 27, 2019
0.4.12 Apr 11, 2018
0.4.11 Jan 14, 2018
0.4.11.dev2 Nov 28, 2017
0.4.11.dev1 Nov 27, 2017
0.4.10 Oct 30, 2017
0.4.9 Jun 09, 2017
0.4.8 Jun 07, 2017
0.4.7 Jun 05, 2017
0.4.6.dev1 May 09, 2017
0.4.6.dev0 May 02, 2017
0.4.5 Apr 25, 2017
0.4.5.dev2 Apr 25, 2017
0.4.5.dev0 Apr 25, 2017
0.4.4 Apr 24, 2017
0.4.3 Mar 24, 2017
0.4.2 Feb 23, 2017
0.4.2.dev1 Feb 17, 2017
0.4.2.dev0 Feb 17, 2017
0.4.1 Feb 17, 2017
0.4.0 Feb 15, 2017
0.3.16 Nov 07, 2016
0.3.15 Oct 20, 2016
0.3.14 Oct 12, 2016
0.3.13 Oct 07, 2016
0.3.12 Sep 07, 2016
0.3.11 Sep 07, 2016
0.3.8 Aug 21, 2016
0.3.7 Aug 16, 2016
0.3.6.dev0 Aug 15, 2016
0.3.5 Aug 11, 2016
0.3.4.dev7 Aug 07, 2016
0.3.4.dev6 Aug 04, 2016
0.3.4.dev5 Aug 04, 2016
0.3.4.dev4 Aug 01, 2016
0.3.4.dev3 Aug 01, 2016
0.3.4.dev2 Aug 01, 2016
0.3.4.dev1 Aug 01, 2016
0.3.4.dev0 Jul 28, 2016
0.3.3 Jul 27, 2016
0.3.3.dev0 Jul 27, 2016
0.3.2 Jul 26, 2016
0.3.2.dev0 Jul 26, 2016
0.3.1 Jul 25, 2016
0.3.0 Jul 25, 2016
0.3.0.dev7 Jul 25, 2016
0.3.0.dev6 Jul 25, 2016
0.3.0.dev5 Jul 25, 2016
0.3.0.dev4 Jul 25, 2016
0.3.0.dev3 Jul 25, 2016
0.3.0.dev2 Jul 25, 2016
0.3.0.dev1 Jul 21, 2016
0.3.0.dev0 Jul 15, 2016
0.2.8 Jun 24, 2016
0.2.7 Mar 01, 2016
0.2.6 Feb 29, 2016
0.2.5 Feb 19, 2016
0.2.4 Feb 18, 2016
0.2.3.2 Jan 21, 2016
0.2.3.1 Jan 19, 2016
0.2.3 Jan 18, 2016
0.2.2 Jan 18, 2016
0.2.1 Jan 12, 2016
0.2 Jan 12, 2016
0.1.5.5 Nov 05, 2015
0.1.5.4 Nov 05, 2015
0.1.5.3 Sep 28, 2015
0.1.5.2 Sep 28, 2015
0.1.5.1 Sep 16, 2015
0.1.5 Sep 16, 2015
0.1.4.2 Jul 25, 2015
0.1.4.1 Jul 23, 2015
0.1.3 Jul 20, 2015
0.1.2.1 Jul 20, 2015
0.1.1 Jul 15, 2015
0.0.13 Jul 14, 2015
0.0.12 Jun 30, 2015
0.0.11 Jun 30, 2015
0.0.10 Jun 18, 2015
0.0.9 May 08, 2015
0.0.8 Apr 24, 2015
0.0.7 Apr 22, 2015
0.0.6 Feb 04, 2015
0.0.5.6 Feb 04, 2015
0.0.5.5 Feb 04, 2015
0.0.5.4 Feb 04, 2015
0.0.5.3 Feb 04, 2015
0.0.5.2 Feb 04, 2015
0.0.5.1 Feb 04, 2015
0.0.5 Feb 04, 2015
0.0.4 Feb 04, 2015
0.0.3 Dec 30, 2014
0.0.2 Dec 29, 2014
0.0.1 Dec 29, 2014

Wheel compatibility matrix

Platform CPython 3.9 CPython 3.10 CPython 3.11 CPython 3.12 CPython 3.13 CPython 3.14 CPython 3.15 PyPy 3.11
any
macosx_11_0_arm64
manylinux_2_28_aarch64
manylinux_2_28_x86_64
win_amd64

Files in release

vmprof-0.5.0-cp310-cp310-macosx_11_0_arm64.whl (50.1KiB)
vmprof-0.5.0-cp310-cp310-manylinux_2_28_aarch64.whl (76.2KiB)
vmprof-0.5.0-cp310-cp310-manylinux_2_28_x86_64.whl (78.3KiB)
vmprof-0.5.0-cp310-cp310-win_amd64.whl (47.8KiB)
vmprof-0.5.0-cp311-cp311-macosx_11_0_arm64.whl (50.2KiB)
vmprof-0.5.0-cp311-cp311-manylinux_2_28_aarch64.whl (76.3KiB)
vmprof-0.5.0-cp311-cp311-manylinux_2_28_x86_64.whl (78.5KiB)
vmprof-0.5.0-cp311-cp311-win_amd64.whl (47.9KiB)
vmprof-0.5.0-cp312-cp312-macosx_11_0_arm64.whl (50.1KiB)
vmprof-0.5.0-cp312-cp312-manylinux_2_28_aarch64.whl (76.2KiB)
vmprof-0.5.0-cp312-cp312-manylinux_2_28_x86_64.whl (78.5KiB)
vmprof-0.5.0-cp312-cp312-win_amd64.whl (47.9KiB)
vmprof-0.5.0-cp313-cp313-macosx_11_0_arm64.whl (50.1KiB)
vmprof-0.5.0-cp313-cp313-manylinux_2_28_aarch64.whl (76.2KiB)
vmprof-0.5.0-cp313-cp313-manylinux_2_28_x86_64.whl (78.5KiB)
vmprof-0.5.0-cp313-cp313-win_amd64.whl (47.9KiB)
vmprof-0.5.0-cp314-cp314-macosx_11_0_arm64.whl (50.1KiB)
vmprof-0.5.0-cp314-cp314-manylinux_2_28_aarch64.whl (76.2KiB)
vmprof-0.5.0-cp314-cp314-manylinux_2_28_x86_64.whl (78.5KiB)
vmprof-0.5.0-cp314-cp314-win_amd64.whl (48.2KiB)
vmprof-0.5.0-cp315-cp315-macosx_11_0_arm64.whl (50.1KiB)
vmprof-0.5.0-cp315-cp315-manylinux_2_28_aarch64.whl (76.2KiB)
vmprof-0.5.0-cp315-cp315-manylinux_2_28_x86_64.whl (78.5KiB)
vmprof-0.5.0-cp315-cp315-win_amd64.whl (48.2KiB)
vmprof-0.5.0-cp39-cp39-macosx_11_0_arm64.whl (50.1KiB)
vmprof-0.5.0-cp39-cp39-manylinux_2_28_aarch64.whl (76.2KiB)
vmprof-0.5.0-cp39-cp39-manylinux_2_28_x86_64.whl (78.3KiB)
vmprof-0.5.0-cp39-cp39-win_amd64.whl (47.9KiB)
vmprof-0.5.0-pp311-none-any.whl (38.0KiB)
Extras: None
Dependencies:
requests
six
colorama