Skip to main content

A simple tool to monitor execution of functions.

Project description

eprofiler

Modern Execution, Memory & Audit Profiler for Python

A lightweight, zero-dependency toolkit to monitor performance and audit function lifecycles. eprofiler provides high-precision decorators and context managers to identify bottlenecks and log execution metadata with minimal friction.

PyPI version

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)

Ideal for production logs where you need to know if a function finished, how long it took, and why it failed. Optinally which args used.

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


Why eprofiler?

  1. Fixed-Width Timing: All durations use :.6f formatting for perfect vertical alignment in logs.
  2. Machine Readable: All outputs are valid Python dictionaries (easily convertible to JSON).
  3. Fail-Safe: The @audit decorator uses logger.exception to ensure stack traces are preserved on failure.
  4. Accuracy Note: When using @profile or @memit, Python's tracemalloc adds a slight overhead. For the most precise timing-only results, use @timeit.

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.8.tar.gz (8.4 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.8-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for eprofiler-0.0.8.tar.gz
Algorithm Hash digest
SHA256 d652f8c69cf0546e2cd9ea725f8a0efcdad75943ea6d39f2262ed9700a358ba7
MD5 74ff6b2dbb0b5da7ccc26bb97935a022
BLAKE2b-256 220785dc1de540ad7bc7e1485a46d86f5c3fce665f07c7824aeb8ca5568b4c6f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for eprofiler-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 027c049f2473808d2739481edc861c0b44ed69c1d190678bf3978eeb0010728d
MD5 1f6ac4e1b85381be98c206b0a4b75ede
BLAKE2b-256 b928ae1afbd95facaa8a916960ce4fd812c69fe14574634af7150e870272ed56

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