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

Commit

Permalink
Refactored benches for null_count.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Aug 26, 2021
1 parent f79ae3e commit d4b6aaa
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ name = "length_kernel"
harness = false

[[bench]]
name = "null_count"
name = "count_zeros"
harness = false

[[bench]]
Expand Down
24 changes: 24 additions & 0 deletions benches/count_zeros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use arrow2::bitmap::utils::null_count;

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

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

let bytes = (0..size as u32)
.map(|x| 0b01011011u8.rotate_left(x))
.collect::<Vec<_>>();

c.bench_function(&format!("count_zeros 2^{}", log2_size), |b| {
b.iter(|| null_count(&bytes, 0, bytes.len() * 8))
});

c.bench_function(&format!("count_zeros offset 2^{}", log2_size), |b| {
b.iter(|| null_count(&bytes, 10, bytes.len() * 8 - 10))
});
})
}

criterion_group!(benches, add_benchmark);
criterion_main!(benches);
42 changes: 0 additions & 42 deletions benches/null_count.rs

This file was deleted.

24 changes: 24 additions & 0 deletions benches/unset_count.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use arrow2::bitmap::utils::null_count;

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

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

let bytes = (0..size as u32)
.map(|x| 0b01011011u8.rotate_left(x))
.collect::<Vec<_>>();

c.bench_function(&format!("unset_count 2^{}", log2_size), |b| {
b.iter(|| null_count(&bytes, 0, bytes.len() * 8))
});

c.bench_function(&format!("unset_count offset 2^{}", log2_size), |b| {
b.iter(|| null_count(&bytes, 10, bytes.len() * 8 - 10))
});
})
}

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

0 comments on commit d4b6aaa

Please sign in to comment.