Skip to main content

Zero-effort performance regression detection for Python

Project description

pytimebudget

Zero-effort performance regression detection for Python.

pytimebudget helps you detect when parts of your code get slower over time, not just slow once. It stores historical timing data and warns you when performance regresses, with almost no setup.

No configuration required.
Just import it and use it.


✨ Features

  • 📉 Regression detection - compares current runtime to historical baseline
  • 💾 SQLite backend - persistent, fast, reliable
  • 📦 Per-project isolation - each project gets its own database automatically
  • Async support - works with async with
  • 🧠 Safe by default – never crashes your code
  • 🔕 Opt-out anytime via environment variable

📦 Installation

pip install pytimebudget

🚀 Quick Start

Basic usage

import pytimebudget
import time

pytimebudget("startup", max_ms=100)
time.sleep(0.08)

If this code becomes significantly slower over time, pytimebudget will warn you.


Context manager (recommended)

import pytimebudget
import time

with pytimebudget("db_query", max_ms=40):
    time.sleep(0.05)

Async support

import pytimebudget
import asyncio

async def main():
    async with pytimebudget("async_task", max_ms=50):
        await asyncio.sleep(0.02)

asyncio.run(main())

🧠 How It Works

For each named timing:

  1. Execution time is measured
  2. The result is stored in a SQLite database
  3. A rolling baseline is calculated
  4. If the current run is significantly slower than the baseline, a warning is emitted

This allows you to catch gradual slowdowns that traditional profiling misses.


📁 Per-Project Isolation

Each project automatically gets its own database, based on the project root (.git, pyproject.toml, or setup.py).

Databases are stored in:

~/.pytimebudget/

This prevents unrelated projects from polluting each other’s timing data.


⚠️ Warnings

When a regression is detected, you’ll see something like:

[pytimebudget] Performance regression detected
  Name:     db_query
  Baseline: 32.14 ms
  Current:  51.87 ms
  Slowdown: 1.61x

You can choose whether this is printed or emitted as a Python warning.


🎯 When Should You Use This?

  • Detect performance regressions in long-lived projects
  • Monitor critical paths (startup, I/O, parsing, DB access)
  • Catch slowdowns before users do
  • Add lightweight performance checks without profiling overhead

This is not a profiler, but it’s a regression detector.


🧪 Stability & Safety

  • Uses only the Python standard library
  • All internal errors are swallowed
  • Never interrupts your application
  • Safe for production use

📄 License

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

pytimebudget-0.1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

pytimebudget-0.1.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file pytimebudget-0.1.1.tar.gz.

File metadata

  • Download URL: pytimebudget-0.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pytimebudget-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5320da74572abb992438cfd645be3d95f57ee46c2b2794c6355b0495c3ca053d
MD5 63adda6761c09aea7c2fac120d4b80e0
BLAKE2b-256 965d824a15b0dc5fb70ea39b34429992c7a6b79b0c281057a4823107fe8cf722

See more details on using hashes here.

File details

Details for the file pytimebudget-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pytimebudget-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pytimebudget-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2f3bf809db12f5182de7d51c521cc3a3b6426107e09dfb1e08ecf9d40ffadad0
MD5 166f8949df5bc5171b4ede7ca3a17ec9
BLAKE2b-256 d6f8ab5eaddbae12433fd6d367aa97348cb71316f85d43e45a623cea2c25c7cb

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