Skip to content

Commit 3b8d106

Browse files
committed
benchmark
Signed-off-by: Alexander Droste <[email protected]>
1 parent 903bca0 commit 3b8d106

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

encodings/alp/benches/alp_compress.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,36 @@ fn decompress_alp<T: ALPFloat + NativePType>(bencher: Bencher, args: (usize, f64
100100
.bench_values(decompress_into_array);
101101
}
102102

103+
#[divan::bench(types = [f32, f64], args = BENCH_ARGS)]
104+
fn decompress_alp_vector<T: ALPFloat + NativePType>(bencher: Bencher, args: (usize, f64, f64)) {
105+
let (n, fraction_patch, fraction_valid) = args;
106+
let mut rng = StdRng::seed_from_u64(0);
107+
let mut values = buffer![T::from(1.234).unwrap(); n].into_mut();
108+
if fraction_patch > 0.0 {
109+
for index in 0..values.len() {
110+
if rng.random_bool(fraction_patch) {
111+
values[index] = T::from(1000.0).unwrap()
112+
}
113+
}
114+
}
115+
let validity = if fraction_valid < 1.0 {
116+
Validity::from_iter((0..values.len()).map(|_| rng.random_bool(fraction_valid)))
117+
} else {
118+
Validity::NonNullable
119+
};
120+
let values = values.freeze();
121+
bencher
122+
.with_inputs(|| {
123+
let alp_array = alp_encode(
124+
&PrimitiveArray::new(Buffer::copy_from(&values), validity.clone()),
125+
None,
126+
)
127+
.unwrap();
128+
alp_array.to_array()
129+
})
130+
.bench_refs(|array| array.execute().unwrap());
131+
}
132+
103133
#[divan::bench(types = [f32, f64], args = [10_000, 100_000])]
104134
fn compress_rd<T: ALPRDFloat>(bencher: Bencher, n: usize) {
105135
let primitive = PrimitiveArray::new(buffer![T::from(1.23).unwrap(); n], Validity::NonNullable);

0 commit comments

Comments
 (0)