Visual profiler for Python
vprof is a Python package providing rich and interactive visualizations for various Python program characteristics such as running time and memory usage. It supports Python 3.4+ and distributed under BSD license.
The project is in active development and some of its features might not work as expected.
All contributions are highly encouraged! You can add new features, report and fix existing bugs and write docs and tutorials. Feel free to open an issue or send a pull request!
Dependencies to build
vproffrom source code: * Python 3.4+ *
npmis required to build
vproffrom sources only.
All Python and
npmmodule dependencies are listed in
vprofcan be installed from PyPI
pip install vprof
vproffrom sources, clone this repository and execute
python3 setup.py deps_install && python3 setup.py build_ui && python3 setup.py install
To install just
python3 setup.py deps_install
vprof -cis a combination of supported modes:
c- CPU flame graph ⚠️ Not available for windows #62
Shows CPU flame graph for.
Runs built-in Python profiler onand displays results.
m- memory graph
Shows objects that are tracked by CPython GC and left in memory after code execution. Also shows process memory usage after execution of each line of.
h- code heatmap
Displays all executed code ofwith line run times and execution counts. can be Python source file (e.g.
testscript.py) or path to package (e.g.
To run scripts with arguments use double quotes
vprof -c cmh "testscript.py --foo --bar"
Modes can be combined
vprof -c cm testscript.py
vprofcan also profile functions. In order to do this, launch
vprofin remote mode:
vprofwill open new tab in default web browser and then wait for stats.
To profile a function run
from vprof import runner
def foo(arg1, arg2): ...
runner.run(foo, 'cmhp', args=(arg1, arg2), host='localhost', port=8000)
cmhpis profiling mode,
portare hostname and port of
vprofserver launched in remote mode. Obtained stats will be rendered in new tab of default web browser, opened by
vprofcan save profile stats to file and render visualizations from previously saved file.
vprof -c cmh src.py --output-file profile.json
writes profile to file and
vprof --input-file profile.json
renders visualizations from previously saved file.
vprof -hfor full list of supported parameters.
To show UI help, press
hwhen visualizations are displayed.
Also you can check
examplesdirectory for more profiling examples.