Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Added benches for bitmap unary.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Sep 2, 2021
1 parent cef5f08 commit 3b987e3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,7 @@ harness = false
[[bench]]
name = "concat"
harness = false

[[bench]]
name = "bitmap_ops"
harness = false
37 changes: 37 additions & 0 deletions benches/bitmap_ops.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use arrow2::bitmap::Bitmap;

use criterion::{criterion_group, criterion_main, Criterion};

fn bench_arrow2(lhs: &Bitmap, rhs: &Bitmap) {
let r = lhs | rhs;
assert!(r.null_count() > 0);
}

fn add_benchmark(c: &mut Criterion) {
(10..=20).step_by(2).for_each(|log2_size| {
let size = 2usize.pow(log2_size);

let bitmap: Bitmap = (0..size).into_iter().map(|x| x % 3 == 0).collect();
c.bench_function(&format!("bitmap aligned not 2^{}", log2_size), |b| {
b.iter(|| {
let r = !&bitmap;
assert!(r.null_count() > 0);
})
});
let bitmap1 = bitmap.clone().slice(1, size - 1);
c.bench_function(&format!("bitmap not 2^{}", log2_size), |b| {
b.iter(|| {
let r = !&bitmap1;
assert!(r.null_count() > 0);
})
});

let bitmap1: Bitmap = (0..size).into_iter().map(|x| x % 4 == 0).collect();
c.bench_function(&format!("bitmap aligned or 2^{}", log2_size), |b| {
b.iter(|| bench_arrow2(&bitmap, &bitmap1))
});
});
}

criterion_group!(benches, add_benchmark);
criterion_main!(benches);

0 comments on commit 3b987e3

Please sign in to comment.