vprof 是一个为不同Python 程序特性提供丰富和交互可视化的包

网友投稿 750 2022-10-31

vprof 是一个为不同Python 程序特性提供丰富和交互可视化的包

vprof 是一个为不同Python 程序特性提供丰富和交互可视化的包

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 2.7, Python 3.4, Python 3.5 and distributed under BSD license.

The project is in active development and some of its features might not work as expected.

Screenshots

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 issue or send pull request!

Prerequisites

The required dependencies to build vprof from source code:

Python 2.7, Python 3.4 or Python 3.5pipnpm >= 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

python setup.py deps_install && python setup.py build_ui && python setup.py install

To install just vprof dependencies, run

python setup.py deps_install

Usage

vprof -c

is a combination of supported modes:

c - CPU flame graph.

Shows CPU flame graph for .

m - memory graph.

Shows objects that are tracked by CPython GC and left in memory after code execution. Also shows process memory usage during execution of each line of .

h - code heatmap.

Displays all executed code of with line execution count.

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

Use double quotes to run scripts with arguments:

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 profilerdef foo(arg1, arg2): ...profiler.run(foo, 'cmh', args=(arg1, arg2), host='localhost', port=8000)

where cmh 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 to file and render profile from file.

vprof -c cmh --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 in browser.

Also you can check examples directory for more profiling examples.

Testing

Just run:

python setup.py test && python setup.py e2e_test

License

BSD

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:首个步态识别框架开源了
下一篇:浅谈@Aspect@Order各个通知的执行顺序
相关文章

 发表评论

暂时没有评论,来抢沙发吧~