Skip to content

Commit

Permalink
add first xor benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
cevian committed Jan 24, 2024
1 parent 7807f41 commit 351e928
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions timescale_vector/benches/distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,14 @@ fn xor_unoptimized_u64_fixed_size(v1: &[u64], v2: &[u64]) -> usize {
result
}

fn xor_unoptimized_u64_fixed_size_map(v1: &[u64], v2: &[u64]) -> usize {
v1[..24]
.iter()
.zip(v2[..24].iter())
.map(|(&l, &r)| (l ^ r).count_ones() as usize)
.sum()
}

fn xor_unoptimized_u128(v1: &[u128], v2: &[u128]) -> usize {
let mut result = 0;
for (b1, b2) in v1.iter().zip(v2.iter()) {
Expand Down Expand Up @@ -310,6 +318,9 @@ fn benchmark_distance_xor(c: &mut Criterion) {
group.bench_function("xor unoptimized u64 fixed size", |b| {
b.iter(|| xor_unoptimized_u64_fixed_size(black_box(&r_u64), black_box(&l_u64)))
});
group.bench_function("xor unoptimized u64 fixed size_map", |b| {
b.iter(|| xor_unoptimized_u64_fixed_size_map(black_box(&r_u64), black_box(&l_u64)))
});
assert!(r_u128.len() == 12);
group.bench_function("xor unoptimized u128 fixed size", |b| {
b.iter(|| xor_unoptimized_u128_fixed_size(black_box(&r_u128), black_box(&l_u128)))
Expand Down

0 comments on commit 351e928

Please sign in to comment.