Skip to content

Commit 31db7e4

Browse files
authored
Merge pull request #7 from ChillFish8/CFAVML-NONE-add-simsimd
CFAVML-NONE: Add `simsimd` back to distance benchmarks
2 parents 3dabd35 + 5aee426 commit 31db7e4

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

cfavml/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ paste = "1.0.14"
2222
divan = "0.1.14"
2323
num-traits = "0.2.19"
2424
mimalloc = { version = "0.1.43", default-features = false }
25+
simsimd = "5.0.1"
2526

2627
[target.'cfg(unix)'.dev-dependencies]
2728
ndarray = { version = "0.15.6", features = ["blas"] }

cfavml/benches/bench_distance_ops.rs

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn main() {
1616
}
1717

1818
#[divan::bench_group(
19-
sample_count = 500,
19+
sample_count = 2500,
2020
sample_size = 5000,
2121
threads = false,
2222
counters = [ItemsCount::new(DIMS)],
@@ -29,7 +29,7 @@ mod dot_product {
2929

3030
use super::*;
3131

32-
#[divan::bench(types = [f32, f64, i8, i16, i32, i64, u8, u16, u32, u64])]
32+
#[divan::bench(types = [f32, f64])]
3333
fn ndarray<T>(bencher: Bencher)
3434
where
3535
Standard: Distribution<T>,
@@ -48,7 +48,18 @@ mod dot_product {
4848
});
4949
}
5050

51-
#[divan::bench(types = [f32, f64, i8, i16, i32, i64, u8, u16, u32, u64])]
51+
#[divan::bench(types = [f32, f64])]
52+
fn simsimd<T>(bencher: Bencher)
53+
where
54+
Standard: Distribution<T>,
55+
T: simsimd::SpatialSimilarity,
56+
{
57+
let (l1, l2) = utils::get_sample_vectors::<T>(DIMS);
58+
59+
bencher.bench_local(|| T::dot(black_box(&l1), black_box(&l2)));
60+
}
61+
62+
#[divan::bench(types = [f32, f64])]
5263
fn cfavml<T>(bencher: Bencher)
5364
where
5465
Standard: Distribution<T>,
@@ -66,7 +77,7 @@ mod dot_product {
6677
}
6778

6879
#[divan::bench_group(
69-
sample_count = 500,
80+
sample_count = 2500,
7081
sample_size = 5000,
7182
threads = false,
7283
counters = [ItemsCount::new(DIMS)],
@@ -104,6 +115,17 @@ mod cosine {
104115
});
105116
}
106117

118+
#[divan::bench(types = [f32, f64])]
119+
fn simsimd<T>(bencher: Bencher)
120+
where
121+
Standard: Distribution<T>,
122+
T: simsimd::SpatialSimilarity,
123+
{
124+
let (l1, l2) = utils::get_sample_vectors::<T>(DIMS);
125+
126+
bencher.bench_local(|| T::cosine(black_box(&l1), black_box(&l2)));
127+
}
128+
107129
#[divan::bench(types = [f32, f64])]
108130
fn cfavml<T>(bencher: Bencher)
109131
where
@@ -122,7 +144,7 @@ mod cosine {
122144
}
123145

124146
#[divan::bench_group(
125-
sample_count = 500,
147+
sample_count = 2500,
126148
sample_size = 5000,
127149
threads = false,
128150
counters = [ItemsCount::new(DIMS)],
@@ -161,6 +183,17 @@ mod euclidean {
161183
});
162184
}
163185

186+
#[divan::bench(types = [f32, f64])]
187+
fn simsimd<T>(bencher: Bencher)
188+
where
189+
Standard: Distribution<T>,
190+
T: simsimd::SpatialSimilarity,
191+
{
192+
let (l1, l2) = utils::get_sample_vectors::<T>(DIMS);
193+
194+
bencher.bench_local(|| T::sqeuclidean(black_box(&l1), black_box(&l2)));
195+
}
196+
164197
#[divan::bench(types = [f32, f64])]
165198
fn cfavml<T>(bencher: Bencher)
166199
where

0 commit comments

Comments
 (0)