Profiling
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.
[]
(https://travis-ci.org/what-studio/profiling)
Installation
This project is under development yet. So you should install it via GitHub instead of PyPI:
pip install git+https://github.com/what-studio/profiling.git
Profiling
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 save result by view
command:
$ python -m profiling profile your-program.py --dump=your-program.prf
$ python -m profiling view your-program.prf
Live-profiling
If your program has a long life time like a web server, profiling result
at the end of progam doesn't help you. You will need a continuos profiler.
It works by 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
Viewer key commands
- q - Quit.
- space - Pause/Resume.
- ↑ and ↓ - Navigate frames.
- → - Expand the frame.
- ← - Fold the frame.
- > - Go to the hotspot.
- esc - Defocus.
- [ and ] - Change sorting colunm.
Licensing
This project is opened under the BSD 3-Clause license.