Skip to content

Commit

Permalink
Added and tested extensively arbitrary word sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaCappelletti94 committed Aug 20, 2024
1 parent 944e2e6 commit aaf941e
Show file tree
Hide file tree
Showing 37 changed files with 1,899 additions and 1,211 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ serde_json = "1.0"
[dev-dependencies]
serde_json = "1.0"
wyhash = "0.5.0"
criterion = { version = "0.5", features = ["html_reports"] }

[features]
default = ["low_precisions", "beta", "plusplus"]
Expand Down Expand Up @@ -118,5 +119,5 @@ debug-assertions = false # Enables debug assertions.
opt-level = 3

[[bench]]
name = "array"
name = "unique_count_from_sorted_iterators"
harness = false
1 change: 0 additions & 1 deletion benches/array.rs

This file was deleted.

43 changes: 43 additions & 0 deletions benches/unique_count_from_sorted_iterators.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//! Benchmarks to evaluate improvements on the unique_count_from_sorted_iterators function.
use criterion::{criterion_group, criterion_main, Criterion, black_box};
use hyperloglog_rs::hybrid::unique_count_from_sorted_iterators;
use hyperloglog_rs::prelude::{iter_var_len_random_values, splitmix64};

fn bench_unique_count_from_sorted_iterators(b: &mut Criterion) {
let mut group = b.benchmark_group("unique_count_from_sorted_iterators");
let mut random_state = 76568342984735313_u64;
// We consider the case of hash of 32 bits in a precision of 18, using 6 bits per register.
let maximal_possible_size = ((1 << 18) * 6) / 32;
let entries: Vec<(Vec<u32>, Vec<u32>)> = (0..200)
.map(|_| {
random_state = splitmix64(random_state);
let mut a =
iter_var_len_random_values::<u32>(0, maximal_possible_size, None, Some(random_state))
.collect::<Vec<u32>>();
random_state = splitmix64(random_state);
let mut b =
iter_var_len_random_values::<u32>(0, maximal_possible_size, None, Some(random_state))
.collect::<Vec<u32>>();
a.sort();
b.sort();

(a, b)
})
.collect();

group.bench_function("unique_count_from_sorted_iterators", |b| {
b.iter(|| {
for (a, b) in &entries {
unique_count_from_sorted_iterators(black_box(a.iter()), black_box(b.iter()));
}
})
});

group.finish();
}


criterion_group!(benches, bench_unique_count_from_sorted_iterators);

criterion_main!(benches);
Loading

0 comments on commit aaf941e

Please sign in to comment.