Skip to main content

Detect Python performance regressions and compare execution traces with lightweight call graph visualization

Project description

OracleTrace — Python Performance Profiler

Detect Python performance regressions and compare execution traces with a lightweight call graph profiler.

OracleTrace Logo

OracleTrace is a lightweight Python performance analysis tool designed to help developers detect performance regressions, compare execution traces, and visualize call graphs in a simple and readable way.

It is ideal for:

  • Detecting performance regressions between script versions
  • Comparing execution time across runs
  • Visualizing function call graphs
  • Lightweight profiling without heavy instrumentation
  • CI performance validation

PyPI PyPI Downloads GitHub Stars GitHub Forks

Documentation: https://kaykcaputo.github.io/oracletrace/


See OracleTrace in action:

OracleTrace CLI demo

Why OracleTrace?

Performance regressions in Python projects are often hard to detect early.

Traditional profilers focus on deep performance analysis, but they are not optimized for quick regression comparison between two executions.

OracleTrace solves this by allowing you to:

  • Run a script and generate an execution trace
  • Export results to JSON
  • Compare two trace files
  • Identify performance differences
  • Detect new or removed functions
  • Measure execution time deltas

Key Features

Performance Regression Detection

Compare two JSON trace files and instantly see:

  • Slower functions
  • Faster functions
  • New functions
  • Removed functions

Execution Trace Analysis

  • Total execution time per function
  • Average time per call
  • Call counts
  • Caller → callee relationships

Call Graph Visualization

Visual tree structure of your program’s execution flow.

JSON Export

Export trace results for:

  • CI performance checks
  • Historical comparison
  • Automation pipelines

CSV Export

Export flat trace metrics for spreadsheets and custom reports.

Flexible Filtering and Focus

  • Ignore functions and files with regex patterns (--ignore)
  • Limit summary output to top N functions (--top)

CI Regression Gates

Use --fail-on-regression with --threshold to make pipelines fail on meaningful slowdowns.

Clean Output

Filters internal Python calls to focus only on your project code.


Installation

pip install oracletrace

Quick Example

Step 1 — Create a script

import time

def process_data():
    time.sleep(0.1)
    calculate_results()

def calculate_results():
    time.sleep(0.2)

def main():
    for _ in range(2):
        process_data()

if __name__ == "__main__":
    main()

Step 2 — Run OracleTrace

oracletrace my_app.py

Export trace to JSON

oracletrace my_app.py --json baseline.json

Compare with a new version

oracletrace my_app.py --json new.json --compare baseline.json

This allows you to detect performance regressions between two executions.

Fail CI when regression exceeds threshold

oracletrace my_app.py --json current.json --compare baseline.json --fail-on-regression --threshold 25

How It Works

OracleTrace uses Python’s built-in sys.setprofile() function to intercept:

  • call
  • return

It measures execution time per function and records caller-callee relationships.

By filtering functions outside your project directory, the output focuses only on relevant application code.


Example Output

Summary table showing top functions by total execution time and average time per call.

Call graph visualization displaying execution flow hierarchy.

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)

Use Cases

  • Detect Python performance regressions in development
  • Compare execution time between versions
  • Lightweight alternative to heavy profilers
  • CI/CD performance monitoring
  • Educational demonstration of call graphs

Requirements

  • Python >= 3.10
  • rich

Contributing

Contributions are welcome.

If you have ideas for improving regression detection, trace comparison, or visualization features, feel free to open an issue or submit a pull request.

To run tests locally:

pytest tests/

Contributors

Thanks to all the people who have contributed to this project:


Recognition


⭐ Support the Project

If you find OracleTrace useful, give it a ⭐ on GitHub:

👉 https://github.com/KaykCaputo/oracletrace

Your support helps improve the project and makes it more visible to others.


Maintained by Kayk Caputo and André Gustavo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oracletrace-2.0.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oracletrace-2.0.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file oracletrace-2.0.0.tar.gz.

File metadata

  • Download URL: oracletrace-2.0.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for oracletrace-2.0.0.tar.gz
Algorithm Hash digest
SHA256 ea2503a5f1f8ec5f36cc20f8ee81bb9b7eba799d1f796fc179c5a3cfee4c175c
MD5 bec016c7e245dbde1cd3a5ec443ab5fc
BLAKE2b-256 d3bfde2a4a65c2f077032793e7211936a3d93c70d40b1470c134693d7c2af104

See more details on using hashes here.

File details

Details for the file oracletrace-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: oracletrace-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for oracletrace-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6fa1f57c138c00bbf29fafdb1aa00eeccba793286e42129157d207ba2c4b6ed
MD5 bb5cbad91041c802cac7358bf1b88d58
BLAKE2b-256 b4d7b57954ed7fe3f154c84239d9cb8b18f6442426263cc3cccea2aec184ca59

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page