Visualize Python performance profiles
Project description
Performance analysis for Python.
tuna is a modern, lightweight Python profile viewer inspired by SnakeViz. It handles runtime and import profiles, has no Python dependencies, uses d3 and bootstrap, and avoids certain errors present in SnakeViz (see below).
Create a runtime profile with
python -mcProfile -o program.prof yourfile.py
or an import profile with
python -X importtime yourfile.py 2> import.log
and show it with
tuna program.prof
Why tuna doesn't show the whole call tree
The whole timed call tree cannot be retrieved from profile data. Python developers made the decision to only store parent data in profiles because it can be computed with little overhead. To illustrate, consider the following program.
import time
def a(t0, t1):
c(t0)
d(t1)
def b():
a(1, 4)
def c(t):
time.sleep(t)
def d(t):
time.sleep(t)
if __name__ == "__main__":
a(4, 1)
b()
The root process (__main__
) calls a()
which spends 4 seconds in c()
and 1 second
in d()
. __main__
also calls b()
which calls a()
, this time spending 1 second in
c()
and 4 seconds in d()
. The profile, however, will only store that c()
spent a
total of 5 seconds when called from a()
, and likewise d()
. The information that the
program spent more time in c()
when called in root -> a() -> c()
than when called in
root -> b() -> a() -> c()
is not present in the profile.
tuna only displays the part of the timed call tree that can be deduced from the profile. SnakeViz, on the other hand, tries to construct the entire call tree, but ends up providing lots of wrong timings.
SnakeViz output. Wrong. | tuna output. Only shows what can be retrieved from the profile. |
Installation
tuna is available from the Python Package Index, so simply do
pip install tuna
to install.
Testing
To run the tuna unit tests, check out this repository and type
pytest
License
This software is published under the GPLv3 license.
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.
Source Distribution
Built Distribution
File details
Details for the file tuna-0.4.2.tar.gz
.
File metadata
- Download URL: tuna-0.4.2.tar.gz
- Upload date:
- Size: 126.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b2d29e041b2fad5d51bcd1902e59617bc2d47cfc3d0bb49eed5c0a154563c65 |
|
MD5 | 4b239d9902eab2103bf54839ffc7d702 |
|
BLAKE2b-256 | 6dfdbcecd198a428c97f93b3b1dbd5f89faf7c68bf516bf7e97306b874c538c3 |
File details
Details for the file tuna-0.4.2-py3-none-any.whl
.
File metadata
- Download URL: tuna-0.4.2-py3-none-any.whl
- Upload date:
- Size: 136.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f59fd857a52b2876d9c0e71afd8e1e96d09f8a14f4504f3540d5d2773bfea1d |
|
MD5 | 6b35780d318b8c1b0c91ac8fc7522282 |
|
BLAKE2b-256 | f03610cec32e11b9c40e5d11c7dbf28dde24384967f322f914768d1d82dd70f9 |