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. It handles runtime and import profiles, is rather small, uses d3 and bootstrap, and avoids certain errors present in 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.2.3.tar.gz (122.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tuna-0.2.3-py2.py3-none-any.whl (122.2 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: tuna-0.2.3.tar.gz
  • Upload date:
  • Size: 122.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2+

File hashes

Hashes for tuna-0.2.3.tar.gz
Algorithm Hash digest
SHA256 20d7fe9f1d9df9fad9d75d677b9aaee7782dc6758bdc119b99d813ee89e24c07
MD5 7d76020b3664020ae3df455e55132629
BLAKE2b-256 e3123c2edfbfe14405898c1b6902ac8717c69735f66de9963dbb5a5b17024418

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tuna-0.2.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 122.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2+

File hashes

Hashes for tuna-0.2.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 26eea5dae609d932b27a71e1db4aacf2a06af9eb281cbc659e04facf304014e9
MD5 2660fc55ac5ad5c3b2aad2c969ec5ff2
BLAKE2b-256 ce39d6c65958d1c601b6b2a3fd5e32e94670240135203f146ef68c8bc7464c14

See more details on using hashes here.

Supported by

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