Skip to main content

A lightweight tool to monitor execution of functions.

Project description

eprofiler

A lightweight, zero-dependency toolkit to monitor execution of functions or code blocks.

PyPI Build Status License Documentation

eprofiler provides decorators and context managers to observe execution time, cpu time, peak memory and arguments used for a function.

for a function or code block you can monitor and log;

  • execution time
  • peak memory usage
  • CPU time
  • parameters passed to a function

Installation

pip install eprofiler

Core Tools

  • @audit: Execution logging with SUCCESS/FAIL status and error capturing.
  • @timeit: Execution timing (microsecond precision).
  • @memit: Simple peak memory tracking using tracemalloc.
  • @profile / @profile_cpu: Combined time, memory, and CPU profiling.
  • Timer: Context manager and/or decorator for granular blocks.

Usage

1. Function Auditing (@audit)

Good for monitoring what parameters are passed to a function/method. where you need to know if a function finished, how long it took, and why it failed and with which parameters.

⚠ Warning:
if parameters passed to function are not printable like str, int or a python object without __str__ or __repr__ that can be used in fstrings its better to use callback to handle them in logging

from eprofiler import audit

@audit(label="PAYMENT_GATEWAY", include_args=True)
def process_payment(user_id, amount):
    # Logic here...
    return True

process_payment(123, 50.0)

Output (Standard Logging):

INFO: {'timestamp': '2026-03-02T10:00:00.123', 'function': 'process_payment', 'label': 'PAYMENT_GATEWAY', 'args': (123, 50.0), 'status': 'SUCCESS', 'elapsed_seconds': '0.045200'}

2. Basic Timing (@timeit)

For quick performance checks during development. By default, results are printed to the console.

from eprofiler import timeit

@timeit(label="Computation")
def my_func():
    return sum(i**2 for i in range(100000))

my_func()

Output:

{'label': 'Computation', 'function': 'my_func', 'duration': 0.008421}

3. Comprehensive Profiling (@profile)

Track time and memory (current and peak) simultaneously.

from eprofiler import profile

@profile(label="Heavy Task")
def memory_intensive():
    return [x for x in range(1000000)]

memory_intensive()

Output:

{'label': 'Heavy Task', 'function': 'memory_intensive', 'duration': 0.041200, 'peak': 324502, 'current': 1204}

4. Advanced: Callbacks & Custom Capture

Instead of printing to the console, you can capture results programmatically.

from eprofiler import audit

def my_db_callback(payload):
    # Send payload to Datadog, Slack, or a Database
    print(f"Captured: {payload['status']} in {payload['elapsed_seconds']}s")

@audit(callback=my_db_callback)
def sync_data():
    pass

Links


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

eprofiler-0.0.9.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

eprofiler-0.0.9-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file eprofiler-0.0.9.tar.gz.

File metadata

  • Download URL: eprofiler-0.0.9.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for eprofiler-0.0.9.tar.gz
Algorithm Hash digest
SHA256 7778a8ee2f22f5eb9f4caf0c2d0e49d8aadaf2aff6c5d3dcca724b7422be1ada
MD5 db5db19815aa32996c89fc58a89bfd89
BLAKE2b-256 46990ab9fd9faaf374b09d41a4d114910c19a889992cd11a8397afe11031ee96

See more details on using hashes here.

File details

Details for the file eprofiler-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: eprofiler-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for eprofiler-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 0077ea5c66680b5852cac7f81040fef2e34d8fda79c5b1b576f17b93945741f5
MD5 f9fa7d4ea55c791b49080a3860b8de86
BLAKE2b-256 cbcc1eac65516e474bb493ba8a13d28f0d545aca63973ac1917da0fae93d8c5b

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