A tool to run memory benchmarks on CPython commits using Memray.
pip install -e .The tool provides a CLI command memory-tracker that can be used to run benchmarks on a range of CPython commits.
# Run benchmarks on a range of commits
memory-tracker benchmark HEAD~5..HEAD
# Specify a custom CPython repository
memory-tracker benchmark /path/to/cpython HEAD~5..HEAD
# Customize build flags
memory-tracker benchmark HEAD~5..HEAD --configure-flags="--enable-optimizations --with-lto" --make-flags="-j8"
# Specify output directory
memory-tracker benchmark HEAD~5..HEAD --output-dir="./my_benchmarks"For each commit, the tool will:
- Checkout the commit
- Build CPython with the specified flags
- Create a virtual environment with the built Python
- Install Memray
- Run all benchmarks in the
benchmarksdirectory - Generate the following files for each benchmark:
.binfile with raw Memray data_stats.jsonwith memory statistics_flamegraph.htmlwith an interactive flamegraphsysconfig.jsonwith system configuration information
To add a new benchmark:
- Create a new Python file in the
benchmarksdirectory - Write your benchmark code
- The file will be automatically discovered and run
Example benchmark:
def my_benchmark():
# Your benchmark code here
pass
if __name__ == '__main__':
my_benchmark()# Create a virtual environment
python -m venv .venv
source .venv/bin/activate
# Install development dependencies
pip install -e ".[dev]"pytest