Skip to content

Commit

Permalink
include patches
Browse files Browse the repository at this point in the history
  • Loading branch information
danking committed Feb 3, 2025
1 parent 210c5e0 commit 7fb595b
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions encodings/alp/benches/alp_compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,32 @@ fn main() {
}

#[divan::bench(types = [f32, f64], args = [
(100_000, 0.0, 0.25),
(100_000, 0.01, 0.25),
(100_000, 0.1, 0.25),
(10_000_000, 0.0, 0.25),
(10_000_000, 0.01, 0.25),
(10_000_000, 0.1, 0.25),
(100_000, 0.0, 0.95),
(100_000, 0.01, 0.95),
(100_000, 0.1, 0.95),
(10_000_000, 0.0, 0.95),
(10_000_000, 0.01, 0.95),
(10_000_000, 0.1, 0.95),
(100_000, 0.0, 1.0),
(100_000, 0.01, 1.0),
(100_000, 0.1, 1.0),
(10_000_000, 0.0, 1.0),
(10_000_000, 0.01, 1.0),
(10_000_000, 0.1, 1.0),
])]
fn compress_alp<T: ALPFloat + NativePType>(bencher: Bencher, args: (usize, f64, f64)) {
let (n, fraction_patch, fraction_valid) = args;
let mut rng = StdRng::seed_from_u64(0);
let mut values = buffer![T::from(1.234).unwrap(); n].into_mut();
if fraction_patch < 1.0 {
if fraction_patch > 0.0 {
for index in 0..values.len() {
if rng.gen_bool(fraction_valid) {
if rng.gen_bool(fraction_patch) {
values[index] = T::from(1000.0).unwrap()
}
}
Expand All @@ -45,32 +51,39 @@ fn compress_alp<T: ALPFloat + NativePType>(bencher: Bencher, args: (usize, f64,
Validity::NonNullable
};
let values = values.freeze();

bencher.bench_local(move || {
alp_encode(&PrimitiveArray::new(values.clone(), validity.clone())).unwrap()
})
}

#[divan::bench(types = [f32, f64], args = [
(100_000, 0.0, 0.25),
(100_000, 0.01, 0.25),
(100_000, 0.1, 0.25),
(10_000_000, 0.0, 0.25),
(10_000_000, 0.01, 0.25),
(10_000_000, 0.1, 0.25),
(100_000, 0.0, 0.95),
(100_000, 0.01, 0.95),
(100_000, 0.1, 0.95),
(10_000_000, 0.0, 0.95),
(10_000_000, 0.01, 0.95),
(10_000_000, 0.1, 0.95),
(100_000, 0.0, 1.0),
(100_000, 0.01, 1.0),
(100_000, 0.1, 1.0),
(10_000_000, 0.0, 1.0),
(10_000_000, 0.01, 1.0),
(10_000_000, 0.1, 1.0),
])]
fn decompress_alp<T: ALPFloat + NativePType>(bencher: Bencher, args: (usize, f64, f64)) {
let (n, fraction_patch, fraction_valid) = args;
let mut rng = StdRng::seed_from_u64(0);
let mut values = buffer![T::from(1.234).unwrap(); n].into_mut();
if fraction_patch < 1.0 {
if fraction_patch > 0.0 {
for index in 0..values.len() {
if rng.gen_bool(fraction_valid) {
if rng.gen_bool(fraction_patch) {
values[index] = T::from(1000.0).unwrap()
}
}
Expand Down

0 comments on commit 7fb595b

Please sign in to comment.