Skip to main content

Your Tool For Python Performance Tracking

Project description

perf8

https://github.com/tarekziade/perf8/actions/workflows/ci.yml/badge.svg?branch=main

THIS IS ALPHA QUALITY, UNSUPPORTED, RUN AT YOUR OWN RISKS

Your Tool For Python Performance Tracking

perf8 is a curated list of tools to track the performance of your Python app.

The project is pluggable, and ships with a few tools:

  • cprofile - a cProfile to Dot graph generator

  • pyspy - a py-spy speedscope generator

  • memray - a memory flamegraph generator

  • psutil - a psutil integration

  • asyncstats - stats on the asyncio eventloop usage (for async apps)

Installation

Use pip:

pip install perf8

If you use the cprofile plugin, you will need to install Graphviz to get the dot utility. See. https://graphviz.org/download/

Usage

Running the perf8 command against your Python module:

perf8 --all -c /my/python/script.py --option1

Will generate a self-contained HTML report, making it suitable for running it in automation and produce performance artifacts.

You can pick specific plugins. Run perf –help and use the ones you want.

Async applications

Running the asyncstats plugin requires to provide your application event loop.

In order to do this, you need to instrument your application to give perf8 the loop to watch. You can use the enable and disable coroutines:

import perf8

async def my_app():
     await perf8.enable(my_loop)
     try:
         # my code
         await run_app()
     finally:
         await perf8.disable()

To avoid running this code in production you can use the PERF8 environment variable to detect if perf8 is calling your app:

import os

if 'PERF8' in os.environ:
    import perf8

    async with perf8.measure():
        await run_app()
 else:
     await run_app()

Screencast

docs/perf8-screencast.gif

0.0.1 - 2023/01/06

  • Initial release

0.0.0 - 2022/11/11

  • Don’t use it.

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

perf8-0.0.1.tar.gz (656.6 kB view details)

Uploaded Source

File details

Details for the file perf8-0.0.1.tar.gz.

File metadata

  • Download URL: perf8-0.0.1.tar.gz
  • Upload date:
  • Size: 656.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for perf8-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7dadf24869cae705b3027a2349611d40134283cbc5900e34be128489fd688e84
MD5 4bbea92405d17db47f1b8801ec53fb06
BLAKE2b-256 ff1d5985968bbca76bedd748eb6a017ba1a2368f925c682eaace3b5454669abb

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