PyPerfStats
A lightweight Python performance profiler that collects CPU, memory, and other system metrics while your script runs.
Installation
pip install pyperfstats
Features
- Simple and intuitive command-line interface
- Collects key system metrics:
- CPU usage
- Memory usage
- Thread count
- Open files and connections
- Disk I/O activity
- Network usage
- Context switches
- Real-time monitoring with interactive terminal UI
- Live graphs and statistics
- Monitor any running process by PID
- Launch and monitor scripts in real-time
- Exports performance data to CSV for custom analysis
- Built-in visualization tools:
- Time-series charts for CPU usage
- Time-series charts for memory usage
- Combined charts for quick analysis
- Advanced multi-metric dashboards
- Generates comprehensive HTML reports
- Profile running processes by PID or launch and profile new scripts
- Statistical analysis with min, max, mean, median, and percentiles
Usage
Profile a Python Script
# Basic profiling
pyperfstats profile your_script.py
# Customize output and sampling rate
pyperfstats profile your_script.py --output stats.csv --interval 0.5
# Pass arguments to your script
pyperfstats profile your_script.py --args "arg1,arg2"
# Generate visualization after profiling
pyperfstats profile your_script.py --visualize
# Generate comprehensive HTML report
pyperfstats profile your_script.py --report
# Live monitoring with terminal UI
pyperfstats profile your_script.py --live
Profile an Existing Process
# Attach to an existing process by PID and save data to CSV
pyperfstats attach 1234
# Live monitoring of an existing process
pyperfstats attach 1234 --live
Direct Live Monitoring
# Monitor a specific process with live terminal UI
pyperfstats live 1234
# Monitor the current Python process
pyperfstats live
Visualize Performance Data
# Generate combined visualization
pyperfstats visualize stats.csv
# Generate specific visualization
pyperfstats visualize stats.csv --type cpu
# Save visualization to file
pyperfstats visualize stats.csv --output performance.png
Generate HTML Report
# Generate comprehensive HTML report
pyperfstats report stats.csv
View Statistics Summary
# View statistical summary of performance data
pyperfstats stats stats.csv
Python API
You can also use PyPerfStats programmatically in your own Python code:
from pyperfstats import PerfProfiler, plot_combined_metrics, monitor_process, generate_html_report
# Profile a script and save to CSV
profiler = PerfProfiler(output_file="stats.csv")
csv_file = profiler.profile_script("your_script.py")
# Visualize results
plot_combined_metrics(csv_file)
# Generate an HTML report
report_path = generate_html_report(csv_file)
print(f"Report generated at: {report_path}")
# Monitor a process in real-time
# This will open an interactive terminal UI
monitor_process(pid=1234)
License
MIT
Metadata
Release files for pyperfstats 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyperfstats-0.1.1.tar.gz | 13.4 kB | Without provenance | Details for pyperfstats-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyperfstats-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pyperfstats-0.1.1-py3-none-any.whl |
Total release size: 27.7 kB
Release files / pyperfstats-0.1.1.tar.gz
| Download URL | pyperfstats-0.1.1.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6cde6e3c9b00f2db81e25b52d862d1edbea59ba87d74cd40eabba8a022929b45
|
|
BLAKE2b-256 checksum How to use checksums |
ddd677e22c51a143337a4b416189e8c12dfee8e287e88c650ff41f1a64a582ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / pyperfstats-0.1.1-py3-none-any.whl
| Download URL | pyperfstats-0.1.1-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bbd0beab6a08b37e50f9c72f489d9784ea0fa2668bae38b9775ebc5e21f9ccd7
|
|
BLAKE2b-256 checksum How to use checksums |
96b94526c73522aa84a02622594206a29d0caa5a0c0be8539305360bf73c4181
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for pyperfstats 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.