Skip to content

Commit

Permalink
better throughput bench for delta
Browse files Browse the repository at this point in the history
  • Loading branch information
lwwmanning committed Oct 10, 2024
1 parent 18d7ae0 commit edb43e8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
4 changes: 2 additions & 2 deletions benches/bitpacking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ fn throughput(c: &mut Criterion) {
let mut group = c
.benchmark_group("throughput");
group.throughput(Throughput::Bytes(N as u64 * size_of::<u16>() as u64));
let mut values = vec![3u16; N];
let mut packed = vec![0; NUM_BATCHES * OUTPUT_BATCH_SIZE];
let mut values: Vec<u16> = (0..N).map(|i| (i % 8) as u16).collect();
let mut packed = vec![0u16; NUM_BATCHES * OUTPUT_BATCH_SIZE];

group.bench_function("compress", |b| {
b.iter(|| {
Expand Down
38 changes: 37 additions & 1 deletion benches/delta.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

use arrayref::{array_mut_ref, array_ref};
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
use std::mem::size_of;

Expand Down Expand Up @@ -42,5 +43,40 @@ fn delta(c: &mut Criterion) {
});
}

criterion_group!(benches, delta);
fn throughput(c: &mut Criterion) {
const WIDTH: usize = 3;
const NUM_BATCHES: usize = 1024;
const N: usize = 1024 * NUM_BATCHES;
const OUTPUT_BATCH_SIZE: usize = 128 * WIDTH / size_of::<u16>();

let mut group = c
.benchmark_group("throughput");
group.throughput(Throughput::Bytes(N as u64 * size_of::<u16>() as u64));
let mut values: Vec<u16> = (0..N).map(|i| (i % 8) as u16).collect();
let mut packed = vec![0u16; NUM_BATCHES * OUTPUT_BATCH_SIZE];

group.bench_function("compress", |b| {
b.iter(|| {
for i in 0..NUM_BATCHES {
BitPacking::pack::<WIDTH>(
array_ref![values, i * 1024, 1024],
array_mut_ref![packed, i * OUTPUT_BATCH_SIZE, OUTPUT_BATCH_SIZE],
);
}
});
});

group.bench_function("decompress", |b| {
b.iter(|| {
for i in 0..NUM_BATCHES {
BitPacking::unpack::<WIDTH>(
array_ref![packed, i * OUTPUT_BATCH_SIZE, OUTPUT_BATCH_SIZE],
array_mut_ref![values, i * 1024, 1024],
);
}
});
});
}

criterion_group!(benches, delta, throughput);
criterion_main!(benches);

0 comments on commit edb43e8

Please sign in to comment.