Detect Python performance regressions and compare execution traces with lightweight call graph visualization
Project description
OracleTrace — Detect Python Performance Regressions with Execution Diff
Detect performance regressions between runs of your Python script in seconds.
|
Fail your CI when performance regresses. OracleTrace is a git diff for performance. Run your script twice and instantly see what got slower — with function-level precision. |
Documentation: https://kaykcaputo.github.io/oracletrace/
Featured in: PyCoder's Weekly #729 • awesome-debugger • awesome-profiling
Installation
pip install oracletrace
Quick Start
1. See where your program spends time instantly:
oracletrace app.py
2. Compare runs and detect regressions:
oracletrace app.py --json baseline.json
oracletrace app.py --json new.json --compare baseline.json
See it in action
See exactly which functions got slower between runs:
Example Output
Starting application...
Iteration 1:
> Processing data...
> Calculating results...
Iteration 2:
> Processing data...
> Calculating results...
Application finished.
Summary:
Top functions by Total Time
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Function ┃ Total Time (s) ┃ Calls ┃ Avg. Time/Call (ms) ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ my_app.py:main │ 0.6025 │ 1 │ 602.510 │
│ my_app.py:process_data │ 0.6021 │ 2 │ 301.050 │
│ my_app.py:calculate_results │ 0.4015 │ 2 │ 200.750 │
└──────────────────────────────┴────────────────┴───────┴─────────────────────┘
Logic Flow:
<module>
└── my_app.py:main (1x, 0.6025s)
└── my_app.py:process_data (2x, 0.6021s)
└── my_app.py:calculate_results (2x, 0.4015s)
Why OracleTrace?
Problem
Performance regressions are hard to detect early.
Solution
OracleTrace compares execution traces and highlights what got slower.
How it works
- Run your script
- Generate a trace
- Compare results
- Identify slowdowns
CI Integration
Fail your pipeline when performance degrades:
oracletrace app.py --json current.json --compare baseline.json --fail-on-regression --threshold 25
Add it to your CI to automatically fail on performance regressions.
Key Features
- Detect slower and faster functions
- Identify new or removed functions
- Execution time and call count analysis
- Call graph visualization
- JSON and CSV export
- Regex-based filtering (
--ignore) - Top-N function focus (
--top) - CI regression gates
CLI Reference
| Flag | Description |
|---|---|
--json |
Export trace to JSON |
--csv |
Export trace to CSV |
--compare |
Compare with another trace |
--fail-on-regression |
Exit with error if regression detected |
--threshold |
Regression percentage threshold |
--ignore |
Ignore functions/files via regex |
--top |
Show top N functions |
Use Cases
Primary
- Detect performance regressions between runs
Secondary
- CI performance validation
- Execution trace inspection
- Call graph visualization
How It Works
OracleTrace uses Python’s sys.setprofile() to intercept function calls and returns.
It measures execution time per function and records caller–callee relationships.
Filtering removes external/internal calls to focus on application code.
Requirements
- Python >= 3.10
- rich
Contributing
Contributions are welcome.
Please read the Contributing Guide for details on how to get started, coding standards, and the contribution process.
Contributors
⭐ Support the Project
If OracleTrace is useful, consider giving it a star:
Maintainers
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 oracletrace-2.0.2.tar.gz.
File metadata
- Download URL: oracletrace-2.0.2.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2e0f7a490cd3d88c3d6baaac9d067db6759e339ab6e990f72296def53d3bd76
|
|
| MD5 |
1b9145e929eb4c0e2af6e9b07b2b19db
|
|
| BLAKE2b-256 |
6b1822201ec5c8c9c6bbb3288e3efff6de21e5e22575d795c8133ca177f98869
|
File details
Details for the file oracletrace-2.0.2-py3-none-any.whl.
File metadata
- Download URL: oracletrace-2.0.2-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cac92882ffc9669af5b7b9d270d119b47f4d2c82e6119859884cbcbcf0524e6
|
|
| MD5 |
c9280da8f9c940d8ac8865023901b3a8
|
|
| BLAKE2b-256 |
fcc6e32ab6943a55b907499ac2ffacc779dce40e6afbb4545a901ecf8f0409b2
|