Skip to main content

Zero-dependency Python performance tracker. Decorate, time, count — then report.

Project description

⚡ pytrackio


The fastest way to add performance tracking to any Python project. One decorator. Zero dependencies. No servers. No config. Just answers.

Tests PyPI version Python License: MIT Zero Dependencies PRs Welcome


pip install pytrackio
from pytrackio import track, timer, counter, report

@track
def process_order(order_id):
    ...

with timer("db_query"):
    results = db.execute(query)

counter("api_calls").increment()
report()
================================================================================
  pytrackio - Performance Report         uptime: 4.21s
================================================================================
  Name                         Calls      Avg      Min      Max      p95      p99  Errors
--------------------------------------------------------------------------------
  process_order                   42   120.34    98.10   310.50   290.10   308.40       -
  db_query                        18    45.20    40.10    89.30    87.20    89.10       -
--------------------------------------------------------------------------------
  Counters
--------------------------------------------------------------------------------
  api_calls: 42
================================================================================

Why pytrackio?

Sometimes you just need to know how fast your code runs, without setting up servers, installing agents, or managing infrastructure.

pytrackio runs inside your process, requires zero setup, and gives you real answers in seconds.

Feature pytrackio
Setup time 30 seconds
External server required None
Dependencies 0
Works in scripts and notebooks Yes
p95 and p99 percentiles Yes
Async support Yes
Thread-safe Yes

Installation

pip install pytrackio

Requirements: Python 3.10+ and zero external dependencies.


Usage

@track - decorate any function

from pytrackio import track

@track
def fetch_user(user_id: int):
    ...

@track
async def send_notification(user_id: int):
    await mailer.send(...)

@track(name="payment_gateway")
def charge_card(amount: float):
    ...

Tracks call count, avg, min, max, p95, p99 latency, error count, and error rate.


timer() - track any code block

from pytrackio import timer

with timer("image_resize"):
    resized = resize_image(img, width=800)

async with timer("external_api"):
    result = await fetch_data()

counter() - named event counters

from pytrackio import counter

counter("cache_hits").increment()
counter("retries").increment(3)
counter("queue_size").decrement()
counter("requests").reset()

print(counter("cache_hits").value)

report() - print everything

from pytrackio import report

report()
report(show_counters=False)
report(colour=False)

Returns the report as a string for logging or alerting.


Export data

from pytrackio import export_json, export_csv, export_dict

export_json("metrics.json")
export_csv("metrics.csv")
data = export_dict()

Raw registry access

from pytrackio import get_registry

registry = get_registry()

for s in registry.all_summaries():
    if s.error_rate > 5.0:
        print(f"{s.name} error rate: {s.error_rate:.1f}%")

registry.reset()

Real-world example

from pytrackio import track, timer, counter, report

@track
def get_product(product_id: int) -> dict:
    counter("db_reads").increment()
    return db.query(Product).get(product_id)

@track
async def checkout(cart_id: int) -> str:
    with timer("payment"):
        result = await payment_gateway.charge(cart_id)
    counter("orders_placed").increment()
    return result["order_id"]

report()

Contributing

See CONTRIBUTING.md - PRs welcome.


Changelog

See CHANGELOG.md for version history.


Author

Deepanshu - Python Developer and Open Source Author. Creator of pytrackio. Building tools that solve real problems for real developers.


License

MIT - free to use, modify, and distribute.

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

pytrackio-0.10.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

pytrackio-0.10.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file pytrackio-0.10.1.tar.gz.

File metadata

  • Download URL: pytrackio-0.10.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pytrackio-0.10.1.tar.gz
Algorithm Hash digest
SHA256 f25a19b7c5a20c72e1381dac5bef5b31e37dc9b5377b4ae61c37bd8417b813ec
MD5 85cd25b477c514363e9653b01e615a60
BLAKE2b-256 5af68b92a89ee9fa40c4a6f1690b5d1e6954232a9409597b5c0b792e8bb2b8ff

See more details on using hashes here.

File details

Details for the file pytrackio-0.10.1-py3-none-any.whl.

File metadata

  • Download URL: pytrackio-0.10.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pytrackio-0.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 25d121df07a65ebee5d6f1162a1146582ae6a029ff19bdeeaaf3c4f0cbe47422
MD5 0c902c055742cd4685a2f2f9378617c8
BLAKE2b-256 2d208483338db99eb8d563db6cfd1f872e3651e53be18ae7f74d2e78422465c3

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