Skip to content

wojons/profiling

 
 

Repository files navigation

Profiling

The profiling package is an interactive Python profiler. It is inspired from Unity 3D profiler. This package provides these features:

  1. Profiling statistics keep the frame stack.
  2. An interactive TUI profiling statistics viewer.
  3. Utilities for remote profiling.
  4. Thread or greenlet aware CPU timer.
  5. Supports both of Python 2 and Python 3.

[Build Status] (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.

About

An interactive Python profiler.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published