Skip to main content

A basic wrapper around cProfile with optional snakeviz integration

Project description

Releases can be installed via pip from

pypi

A simple library for a one-liner performance profile using cProfile

and snakeviz! Upon import, will profile your code (profile file will

be stats.prof in your current working directory) and launch

snakeviz to visualize it. The snakeviz webserver will be open for

about 5 seconds before it gets killed by ez_profile. The webpage

will still be visible and interactable though, until you refresh the

page.

There is a problem with IDLE where the webserver may not be killed, but

a SystemError will get raised. This is a known problem and appears

to be an issue with IDLE and/or Python itself. If I find a solution, I

will fix the problem, but for now IDLE is considered incompatible with

ez_profile.

This is meant for internal usage, but if you dont want ez_profile to

profile your code, you can pass the --ignore commandline flag. This

will bypass ez_profile completely.

Notes about usage: import ez_profile should be at the top of your

main file. It profiles the entire project, and to do so, it runs the

main file in a separate process. If you put this anywhere else in your

project, the part before import ez_profile will not be profiled, and

the whole project will be killed after the profiling is completed.

Usage:

# note that this should be at the top of your script

import ez_profile # this is all you need



<all of your other code>

New in 0.1.6 --fname commandline argument to specify where you

want the output profile to be saved

python file.py --fname "/path/to/custom/location/file.prof"

python file.py --fname "custom_filename.prof"

Credit for the idea goes to matiiss

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

ez_profile-0.1.6.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file ez_profile-0.1.6.tar.gz.

File metadata

  • Download URL: ez_profile-0.1.6.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for ez_profile-0.1.6.tar.gz
Algorithm Hash digest
SHA256 e0537ca5551d1d125062028c05ca1932c39516c1b9aea81d3c8c69b411d7c5df
MD5 450bd547b8d4eedf35109eeeb3ddf556
BLAKE2b-256 55440d23a6945b84fe70c22b2e42e482b8f3bbc1a87c68f764177ada88d7a448

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