- Python 62%
- JavaScript 12.2%
- C++ 7.5%
- TypeScript 5.9%
- Rust 5%
- Other 7.4%
| src/py_perf | ||
| .gitignore | ||
| .python-version | ||
| graph-20261102_113241.png | ||
| INVESTIGATION.md | ||
| Makefile | ||
| package-lock.json | ||
| package.json | ||
| perf_cpp.cpp | ||
| perf_go.go | ||
| perf_js.js | ||
| perf_python_312.py | ||
| perf_python_315.py | ||
| perf_rust.rs | ||
| perf_rust_release | ||
| perf_tmp.py | ||
| perf_ts.js | ||
| perf_ts.ts | ||
| pyproject.toml | ||
| README.md | ||
| results-20261102_113241.md | ||
| run_tests.py | ||
| tsconfig.json | ||
| uv.lock | ||
Performance Testing Suite
This suite compares implementations of sum((i * i) % 97) over i in [0, 10,000,000). Each benchmark runs four jobs; the runner tests configurations of 1, 4, and 8 threads, three times each, and averages the elapsed times.
Setup
Install Go, Rust (rustc), clang++, Node.js, and Python 3.12. The runner expects Python 3.12 at /opt/homebrew/opt/python@3.12/bin/python3.12; change python312 in run_tests.py if it is installed elsewhere.
Create the project virtual environment with Python 3.15 or newer and install the dependencies (including matplotlib for the graph):
uv sync
The runner uses .venv/bin/python for the Python 3.15 benchmark. It labels that benchmark free-threaded, but the interpreter must actually be a free-threaded build for that comparison to be valid. The benchmark prints whether the GIL is enabled when run directly.
Make commands
| Command | Effect |
|---|---|
make or make all |
Build the Go, Rust, and C++ binaries. |
make build |
Build all three binaries in /tmp. |
make build-go |
Build /tmp/perf_go_bin. |
make build-rust |
Build /tmp/perf_rust with optimization and LTO. |
make build-cpp |
Build /tmp/perf_cpp with -O2 and pthreads. |
make run |
Build all three binaries, then run .venv/bin/python run_tests.py to benchmark and generate a report. |
make clean |
Remove the three /tmp binaries and results-*.md and graph-*.png in the current directory. |
make run also rebuilds the binaries as perf_go_bin, perf_rust, and perf_cpp in the project directory; make clean does not remove those copies. The runner writes a timestamped results-YYYYMMDD_HHMMSS.md report and, when matplotlib is available, a corresponding graph-YYYYMMDD_HHMMSS.png in the project directory.
The runner benchmarks Go, Rust, C++, JavaScript (perf_js.js), Python 3.12, and the virtual environment's Python. TypeScript (perf_ts.ts and perf_ts.js) and perf_tmp.py are not part of make run. Individual benchmark programs accept NUM_THREADS (default 4), for example:
NUM_THREADS=1 .venv/bin/python perf_python_315.py
The runner uses program-reported elapsed time when available and otherwise falls back to subprocess wall time. It does not check benchmark subprocess exit codes, so inspect the environment and output if results look suspicious.