The profiling package is an interactive Python profiler. It is inspired from Unity 3D profiler. This package provides these features:
- Profiling statistics keep the frame stack.
- An interactive TUI profiling statistics viewer.
- Utilities for remote profiling.
- Thread or greenlet aware CPU timer.
- Supports both of Python 2 and Python 3.
[![Build Status] (https://travis-ci.org/what-studio/profiling.svg)] (https://travis-ci.org/what-studio/profiling) [![Coverage Status] (https://coveralls.io/repos/what-studio/profiling/badge.png)] (https://coveralls.io/r/what-studio/profiling)
This project is still under development, so you should install it via GitHub instead of PyPI:
pip install git+https://github.com/what-studio/profiling.git
To profile a single program, simply run profile
command:
$ python -m profiling profile your-program.py
Then an interactive viewer will be executed:
If your program uses greenlets, choose greenlet
timer:
$ python -m profiling profile your-program.py --timer=greenlet
With --dump
option, it saves the profiling result to a file. You can
browse the saved result by using the view
command:
$ python -m profiling profile your-program.py --dump=your-program.prf
$ python -m profiling view your-program.prf
If your program has a long life time like a web server, profiling result
at the end of program doesn't help you. You will need a continuous profiler.
It works via live-profile
command:
$ python -m profiling live-profile webserver.py
See a demo.
There's a live-profiling server also. The server doesn't profile the
program at ordinary times. But when a client connects to the server, it
runs profiler and reports to the all connected clients. Start a server
with remote-profile
command:
$ python -m profiling remote-profile webserver.py --bind 127.0.0.1:8912
Then run a client with view
command:
$ python -m profiling view 127.0.0.1:8912
- q - Quit.
- space - Pause/Resume.
- ↑ and ↓ - Navigate frames.
- → - Expand the frame.
- ← - Fold the frame.
- > - Go to the hotspot.
- esc - Defocus.
- [ and ] - Change sorting colunm.
This project is licensed under the BSD 3-Clause license.