This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved performance of
SlicesIterator
(15%) (#824)
- Loading branch information
1 parent
7e25ef2
commit d8093bf
Showing
3 changed files
with
42 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
|
||
use arrow2::bitmap::{utils::SlicesIterator, Bitmap}; | ||
|
||
fn bench_slices(lhs: &Bitmap) { | ||
let set_count = lhs.len() - lhs.null_count(); | ||
let slices = SlicesIterator::new(lhs); | ||
|
||
let count = slices.fold(0usize, |acc, v| acc + v.1); | ||
assert_eq!(count, set_count); | ||
} | ||
|
||
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 slices 2^{}", log2_size), |b| { | ||
b.iter(|| bench_slices(&bitmap)) | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, add_benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters