MCPcopy
hub / github.com/nvdv/vprof

github.com/nvdv/vprof @v0.38 sqlite

repository ↗ · DeepWiki ↗ · release v0.38 ↗
310 symbols 656 edges 38 files 162 documented · 52%
README

PyPI

vprof

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.

Screenshots

vprof-gif

Contributing

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!

Prerequisites

Dependencies to build vprof from source code: * Python 3.4+ * pip * npm >= 3.3.12

npm is required to build vprof from sources only.

Dependencies

All Python and npm module dependencies are listed in package.json and requirements.txt.

Installation

vprof can be installed from PyPI

pip install vprof

To build vprof from sources, clone this repository and execute

python3 setup.py deps_install && python3 setup.py build_ui && python3 setup.py install

To install just vprof dependencies, run

python3 setup.py deps_install

Usage

vprof -c <config> <src>

<config> is a combination of supported modes:

  • c - CPU flame graph ⚠️ Not available for windows #62

Shows CPU flame graph for <src>.

  • p - profiler

Runs built-in Python profiler on <src> and 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 <src>.

  • h - code heatmap

Displays all executed code of <src> with line run times and execution counts.

<src> can be Python source file (e.g. testscript.py) or path to package (e.g. myproject/test_package).

To run scripts with arguments use double quotes

vprof -c cmh "testscript.py --foo --bar"

Modes can be combined

vprof -c cm testscript.py

vprof can also profile functions. In order to do this, launch vprof in remote mode:

vprof -r

vprof will 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)

where cmhp is profiling mode, host and port are hostname and port of vprof server launched in remote mode. Obtained stats will be rendered in new tab of default web browser, opened by vprof -r command.

vprof can 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.

Check vprof -h for full list of supported parameters.

To show UI help, press h when visualizations are displayed.

Also you can check examples directory for more profiling examples.

Testing

python3 setup.py test_python && python3 setup.py test_javascript && python3 setup.py e2e_test

License

BSD

Core symbols most depended-on inside this repo

run
called by 16
vprof/base_profiler.py
run
called by 6
setup.py
_skip_lines
called by 5
vprof/code_heatmap.py
getTruncatedNodeName_
called by 5
vprof/ui/flame_graph.js
_trace_memory_usage
called by 4
vprof/memory_profiler.py
_transform_stats
called by 4
vprof/profiler.py
_calc_skips
called by 4
vprof/code_heatmap.py
get_run_object_type
called by 4
vprof/base_profiler.py

Shape

Method 204
Class 54
Function 42
Route 10

Languages

Python80%
TypeScript20%

Modules by API surface

setup.py35 symbols
vprof/tests/base_profiler_test.py20 symbols
vprof/memory_profiler.py19 symbols
vprof/code_heatmap.py19 symbols
vprof/base_profiler.py19 symbols
vprof/ui/flame_graph.js17 symbols
vprof/flame_graph.py16 symbols
vprof/tests/profiler_e2e.py13 symbols
vprof/tests/memory_profiler_e2e.py13 symbols
vprof/tests/flame_graph_e2e.py13 symbols
vprof/tests/code_heatmap_test.py13 symbols
vprof/tests/code_heatmap_e2e.py13 symbols

Dependencies from manifests, versioned

browserify13 · 1×
browserify-csslatest · 1×
d34.9.1 · 1×
eslintlatest · 1×
highlight.jslatest · 1×
jest18.0.0 · 1×
uglify-es3.0.24 · 1×
watchify3.7.0 · 1×
psutil3 · 1×

For agents

$ claude mcp add vprof \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact