A lightweight tool to monitor execution of functions.
Project description
eprofiler
A lightweight, zero-dependency toolkit to monitor execution of functions or code blocks.
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 withSUCCESS/FAILstatus and error capturing.@timeit: Execution timing (microsecond precision).@memit: Simple peak memory tracking usingtracemalloc.@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 likestr,intor 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
- PyPI: https://pypi.org/project/eprofiler/
- GitHub: https://github.com/eyukselen/eprofiler
- Docs: https://eprofiler.readthedocs.io
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7778a8ee2f22f5eb9f4caf0c2d0e49d8aadaf2aff6c5d3dcca724b7422be1ada
|
|
| MD5 |
db5db19815aa32996c89fc58a89bfd89
|
|
| BLAKE2b-256 |
46990ab9fd9faaf374b09d41a4d114910c19a889992cd11a8397afe11031ee96
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0077ea5c66680b5852cac7f81040fef2e34d8fda79c5b1b576f17b93945741f5
|
|
| MD5 |
f9fa7d4ea55c791b49080a3860b8de86
|
|
| BLAKE2b-256 |
cbcc1eac65516e474bb493ba8a13d28f0d545aca63973ac1917da0fae93d8c5b
|