Yet Another Python Profiler
Project description
Yappi
Yet Another Python Profiler, but this time thread&coroutine aware.
Highlights
- Fast: Yappi is fast. It is completely written in C and lots of love&care went into making it fast.
- Unique: Yappi supports multithreaded and asynchronous code profiling. Tagging/filtering multiple profiler results has interesting use cases.
- Intuitive: Profiler can be started/stopped and results can be obtained from any time and any thread.
- Standarts Complaint: Profiler results can be saved in callgrind or pstat formats.
- Rich in Feature set: Profiler results can show either Wall Time or actual CPU Time and can be aggregated from different sessions. Various flags are defined for filtering and sorting profiler results.
- Robust: Yappi had seen more than 8 years of production usage.
Motivation
CPython standard distribution comes with three deterministic profilers. cProfile
, Profile
and hotshot
. cProfile
is implemented as a C module based on lsprof
, Profile
is in pure Python and hotshot
can be seen as a small subset of a cProfile. The major issue is that all of these profilers lack support for multi-threaded programs and CPU time.
If you want to profile a multi-threaded application, you must give an entry point to these profilers and then maybe merge the outputs. None of these profilers are designed to work on long-running multi-threaded applications. It is also not possible to profile an application that start/stop/retrieve traces on the fly with these profilers.
Now fast forwarding to 2019: With the latest improvements on asyncio
library and asynchronous frameworks, most of the current profilers lacks the ability to show correct wall/cpu time or even call count information per-coroutine. Thus we need a different kind of approach to profile asynchronous code. Yappi, with v1.2 introduces the concept of coroutine profiling
. With coroutine-profiling
, you should be able to profile correct wall/cpu time and call count of your coroutine. (including the time spent in context switches, too). You can see details here.
Installation
Can be installed via PyPI
$ pip install yappi
OR from the source directly.
$ pip install git+https://github.com/sumerc/yappi#egg=yappi
Documentation
-
Coroutine Profiling (new in 1.2)
Note: Yes. I know I should be moving docs to readthedocs.io. Stay tuned!
Limitations:
- Threads must be derived from "threading" module's Thread object.
Related Talks
Special thanks to A.Jesse Jiryu Davis:
PyCharm Integration
Yappi is the default profiler in PyCharm
. If you have Yappi installed, PyCharm
will use it. See the official documentation for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.