Non-invasive performance metrics collection for Python applications, inspired by Node.js clinic.
- Non-invasive monitoring: Collect performance metrics without modifying your code
- System metrics: CPU usage, memory consumption, I/O operations, context switches
- Python stack analysis: Categorize frames into application, library, and core code
- Binary metrics format: Efficient storage and parsing of performance data
- Web dashboard: Interactive visualization of collected metrics
- Cross-platform: Supports Linux, macOS, and other Unix-like systems
pip install clinic-py
python -m clinic_py run your_script.py
This will execute your script and collect performance metrics in the .clinic_py/
directory.
python -m clinic_py serve
Then open http://localhost:8000 in your browser to explore the performance data.
# Run a script under monitoring
python -m clinic_py run [--outdir DIR] script.py
# Serve web dashboard
python -m clinic_py serve [--outdir DIR] [--port PORT]
--outdir
: Directory where metrics are stored (default:.clinic_py
)--port
: Port for the web dashboard (default: 8000)
clinic-py uses a C extension to periodically sample system resources with minimal overhead:
- Resource Sampling: Collects CPU time, memory usage, I/O counters using
getrusage()
- Stack Sampling: Analyzes Python call stacks to categorize code execution
- Binary Storage: Writes metrics to efficient binary format
- Web Visualization: Provides interactive charts and summaries
- Python 3.9+
- Unix-like operating system (Linux, macOS, etc.)
- C compiler for building the extension
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit issues and pull requests.