Skip to content

Commit

Permalink
one more bench improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
lwwmanning committed Apr 3, 2024
1 parent 67e1e75 commit e88374f
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions vortex-fastlanes/benches/bitpacking.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use fastlanez::TryBitPack;
use rand::distributions::Uniform;
use rand::{thread_rng, Rng};
use vortex_fastlanes::{bitpack_primitive, unpack_primitive, unpack_single_primitive};
Expand All @@ -23,21 +24,32 @@ fn pack_unpack(c: &mut Criterion) {
let bits: usize = 8;
let values = values(1_000_000, bits);

c.bench_function("bitpack_primitive", |b| {
c.bench_function("bitpack_1M", |b| {
b.iter(|| black_box(bitpack_primitive(&values, bits)));
});

let packed = bitpack_primitive(&values, bits);
c.bench_function("unpack_primitive", |b| {
c.bench_function("unpack_1M", |b| {
b.iter(|| black_box(unpack_primitive::<u32>(&packed, bits, values.len())));
});

c.bench_function("unpack_all_singles", |b| {
c.bench_function("unpack_1M_singles", |b| {
b.iter(|| black_box(unpack_singles(&packed, 8, values.len())));
});

c.bench_function("unpack_single_primitive", |b| {
b.iter(|| black_box(unsafe { unpack_single_primitive::<u32>(&packed, 8, 0) }));
// 1024 elements pack into `128 * bits` bytes
let packed_1024 = &packed[0..128 * bits];
let mut output: Vec<u32> = Vec::with_capacity(1024);
c.bench_function("unpack_1024", |b| {
b.iter(|| {
output.clear();
TryBitPack::try_unpack_into(packed_1024, bits, &mut output).unwrap();
black_box(output[0])
})
});

c.bench_function("unpack_single", |b| {
b.iter(|| black_box(unsafe { unpack_single_primitive::<u32>(packed_1024, 8, 0) }));
});
}

Expand Down

0 comments on commit e88374f

Please sign in to comment.