Skip to main content

Visualize Python profiles in the browser

Project description

tuna

CircleCI Code style: black PyPi Version GitHub stars

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

  1. bump the __version__ number,

  2. tag and upload to PyPi:

    make publish
    

License

tuna is published under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tuna-0.1.2.tar.gz (115.3 kB view details)

Uploaded Source

Built Distribution

tuna-0.1.2-py2.py3-none-any.whl (115.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file tuna-0.1.2.tar.gz.

File metadata

  • Download URL: tuna-0.1.2.tar.gz
  • Upload date:
  • Size: 115.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tuna-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a0c656e77b1c64a93ddf3a727948ca4a048a75a9cb53bd3bdb2a22c7ecfba5b6
MD5 ddeb9e736d2d3d9f1985e40bead370ae
BLAKE2b-256 3c153d986177c9a778d5bd1d0e4b82ed02fae77f86499d9722b18ef83bbf759b

See more details on using hashes here.

File details

Details for the file tuna-0.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for tuna-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c2696f0b79ba4134b8fca2b5b22741e5fe1796de02ce613df8c2fe3cb3d49b12
MD5 1ae1f14e901fbd238663e071eb9da70b
BLAKE2b-256 ccc104e11ad522a7d9ce776f91f509b2232f4e5cb06da8d4bc0540896e23fc7e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page