🚀 EZ-Audit
Zero-Config Performance Monitoring for Python
EZ-Audit is a lightweight, "zero-dependency" tool designed for developers who need to track code performance without the bloat of enterprise monitoring suites. With a single decorator, you can audit execution time and peak memory consumption.
✨ Key Features
⏱️ Microsecond Accuracy: Precise execution timing using time.perf_counter.
🧠 Memory Profiling: Tracks peak RAM usage during a function's lifecycle.
🛡️ Crash-Safe Logging: Records data even if your function raises an exception.
⚠️ Threshold Alerts: Automatically flags functions that exceed your defined time limits.
🪶 Zero-Weight: Built entirely on the Python Standard Library (no external dependencies).
📦 Installation
Install directly from your local source (while in the ez-audit folder):
code
Bash
pip install .
For development (editable mode):
code
Bash
pip install -e .
🚀 Quick Start
Basic Usage
Just drop the @monitor decorator onto any function you want to track.
code
Python
from ezaudit import monitor

@monitor
def process_data():
    # Your logic here
    data = [x for x in range(1000000)]
    return "Done!"

process_data()
Advanced: Threshold Alerts
Get a warning if a function takes longer than expected.
code
Python
@monitor(threshold_sec=0.5)
def slow_service():
    import time
    time.sleep(1) # This will trigger a [THRESHOLD EXCEEDED] warning
🛠️ Configuration
You can customize where logs are saved and whether they print to the console.
code
Python
import ezaudit

ezaudit.configure(
    log_file="performance.log", 
    console_output=True
)
📊 Sample Output
Console Output
code
Text
[EZ-AUDIT] Function: process_data | Status: SUCCESS | Duration: 0.0421s | Peak RAM: 38.21MB
⚠️ [THRESHOLD EXCEEDED] Function: slow_service | Status: SUCCESS | Duration: 1.002s | Peak RAM: 0.01MB
Audit Log (audit.log)
code
Text
2026-02-08 17:05:01 | INFO | Function: process_data | Status: SUCCESS | Duration: 0.0421s | Peak RAM: 38.21MB
2026-02-08 17:05:10 | WARNING | ⚠️ [THRESHOLD EXCEEDED] Function: slow_service | Status: SUCCESS | Duration: 1.002s | Peak RAM: 0.01MB
🛡️ Error Handling
If your code fails, EZ-Audit catches the context before the crash:
code
Text
[EZ-AUDIT] Function: db_connect | Status: FAILED | Duration: 0.001s | Peak RAM: 0.02MB | Error: ConnectionError
📜 License
Distributed under the MIT License. See LICENSE for more information.
