Visualize Python profiles in the browser
Project description
tuna
tuna is a Python profile viewer inspired by the amazing SnakeViz.
Create a runtime profile with
python -mcProfile -o program.prof yourfile.py
or an import profile with
python -X importprofile yourfile.py 2> import.log
and show it with
tuna program.prof
But tuna doesn't show the whole call tree!
Right, and that's because 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)
return
def b():
return a(1, 4)
def c(t):
time.sleep(t)
return
def d(t):
time.sleep(t)
return
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:
Installation
tuna is available from the Python Package Index, so simply type
pip install -U tuna
to install or upgrade.
Testing
To run the tuna unit tests, check out this repository and type
pytest
Distribution
To create a new release
-
bump the
__version__
number, -
tag and upload to PyPi:
make publish
License
tuna is published under the MIT 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.1.4.tar.gz
.
File metadata
- Download URL: tuna-0.1.4.tar.gz
- Upload date:
- Size: 116.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d76e3a0e07cf1919190c2753c786f5ade8c5fff5ef6ad2a244dec6edc46ad68a |
|
MD5 | a1bd1e8c8e87e6e2d0e3c06ad02f8301 |
|
BLAKE2b-256 | 02b4cd8b1ea4f6cde81d60111385062e95462fc284771a58a66410550d6d70ec |
File details
Details for the file tuna-0.1.4-py2.py3-none-any.whl
.
File metadata
- Download URL: tuna-0.1.4-py2.py3-none-any.whl
- Upload date:
- Size: 117.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a940d90c242f0750d0bd1732bc7dc0c1643836b1ec774e3e41f402530f6d9be |
|
MD5 | d6d1d1d16ccd7f81737c5451426424c4 |
|
BLAKE2b-256 | d7f325d6092ed0cbef8eb9a198d0dc9d27c3887e60773927a616f3ca7ee28c56 |