This repository was archived by the owner on May 19, 2026. It is now read-only.
Repository files navigation vector-rs Benchmarks and Setup
Install Rust: https://rustup.rs/
Clone this repo
Build and run native Rust benchmark:
cargo run --release --bin bench
2. Python (PyO3/Rust extension)
Install Python 3.10+
Create and activate a virtual environment:
python -m venv .venv
.venv\S cripts\a ctivate # Windows
source .venv/bin/activate # Linux/macOS
Install dependencies:
pip install maturin uv
uv pip install py-ballisticcalc[exts]==2.2.0rc2
maturin develop
Run Rust/PyO3 benchmark:
python benchmark_vector.py
3. Python (Cython/C extension)
Ensure py-ballisticcalc[exts] is installed in your venv
Build Cython benchmark:
pip install cython setuptools
python setup_bench_cython_v3d.py build_ext --inplace
Run Cython/C benchmark:
python -c " import bench_cython_v3d; bench_cython_v3d.bench_v3d()"
Benchmark Results (1,000,000 calls)
Operation
Rust Native
PyO3 (Rust in Python)
Cython/C (v3d)
Rust (glam)
add
0.0010 s
0.1161 s
0.0010 s
0.0010 s
sub
0.0010 s
0.1149 s
0.0010 s
0.0010 s
neg
0.0010 s
0.0852 s
0.0010 s
0.0011 s
mul_scalar
0.0010 s
0.1196 s
0.0010 s
0.0011 s
dot
0.0010 s
0.0890 s
0.0010 s
0.0010 s
mag
0.0013 s
0.0610 s
0.0011 s
0.0010 s
norm
0.0012 s
0.0923 s
0.0011 s
0.0010 s
eq_false
0.0000 s
0.0654 s
0.0011 s
0.0000 s
eq_true
0.0010 s
0.0653 s
0.0011 s
0.0000 s
Additional: Rust (glam) SIMD Benchmark
Uses the glam crate for SIMD-optimized vector math.
To run:
cargo run --release --bin bench1
Results show glam is as fast as hand-written Rust and Cython/C for these operations.
Follow installation steps for each method above.
Run the provided benchmark scripts/commands.
Compare the output to the table above.
Native Rust and Cython/C are extremely fast for vector math.
PyO3/Rust in Python is much slower due to Python/Rust FFI overhead.
For maximum performance in Python, prefer Cython/C or batch operations in Rust.
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
You can’t perform that action at this time.