Similarities Benchmarks
March 23, 2026 · View on GitHub
All-pairs distance matrix benchmarks comparing NumKong packed kernels against ndarray and nalgebra.
Rust
| Library | Precision | GSO/s |
|---|---|---|
| Angular | ||
numkong::angulars_packed | i8 → f32 | 830.13 |
numkong::angulars_packed | u8 → f32 | 830.14 |
numkong::angulars_packed | bf16 → f32 | 502.45 |
numkong::angulars_packed | f32 → f64 | 92.52 |
ndarray angular | f32 → f32 | 56.98 |
nalgebra angular | f32 → f32 | 49.95 |
ndarray angular | f64 → f64 | 28.82 |
nalgebra angular | f64 → f64 | 27.26 |
numkong::angulars_packed | f64 → f64 | 22.81 |
| Euclidean | ||
numkong::euclideans_packed | i8 → f32 | 887.85 |
numkong::euclideans_packed | u8 → f32 | 888.74 |
numkong::euclideans_packed | bf16 → f32 | 524.00 |
numkong::euclideans_packed | f32 → f64 | 92.93 |
ndarray euclidean | f32 → f32 | 57.64 |
nalgebra euclidean | f32 → f32 | 49.79 |
ndarray euclidean | f64 → f64 | 28.82 |
nalgebra euclidean | f64 → f64 | 27.11 |
numkong::euclideans_packed | f64 → f64 | 22.85 |
| Hamming | ||
numkong::hammings_packed | u1x8 | 9821 |
| Jaccard | ||
numkong::jaccards_packed | u1x8 | 3173 |
Python
| Library | Precision | GSO/s |
|---|---|---|
numkong.euclideans_packed | u8 → f32 | 425.91 |
numkong.euclideans_packed | i8 → f32 | 408.64 |
numkong.angulars_packed | i8 → f32 | 386.96 |
numkong.angulars_packed | u8 → f32 | 364.01 |
numkong.angulars_packed | f32 → f64 | 79.26 |
numkong.euclideans_packed | f32 → f64 | 52.95 |
scipy.cdist euclidean | f32 → f64 | 5.09 |
scipy.cdist cosine | f32 → f64 | 1.30 |
Run It
Rust
``$\text{bash}
\text{Default} 2048 \times 2048 \text{pairs} \text{at} 2048 \text{dimensions}
\text{cargo} \text{bench} --\text{bench} \text{bench_similarities} --\text{features} \text{bench_similarities}
\text{Smaller} 256 \times 256 \text{pairs} \text{at} 256 \text{dimensions}
\text{NUMWARS_DIMS}=256
\text{cargo} \text{bench} --\text{bench} \text{bench_similarities} --\text{features} \text{bench_similarities}
\text{Focus} \text{on} \text{one} \text{metric}
\text{NUMWARS_FILTER}="\text{similarities}/\text{angulars}/\text{f32}"
\text{cargo} \text{bench} --\text{bench} \text{bench_similarities} --\text{features} \text{bench_similarities}
$``
Python
# Run the Python suite
python similarities/bench.py