Skip to content

Commit

Permalink
Merge #222
Browse files Browse the repository at this point in the history
222: Introduce `insert_range` for RoaringTreemap r=Kerollmops a=not-jan

Implemented a somewhat naive version of `insert_range` for RoaringTreemap

~~I wanted to add a separate benchmark to compare the performance of `insert_range` with collecting from an iterator but was unable to do so because `cargo bench` would fail with a connection error every time I ran it.~~
**Edit:** This is fixed now with #225

Co-authored-by: saik0 <[email protected]>
Co-authored-by: not-jan <[email protected]>
  • Loading branch information
3 people authored Sep 1, 2022
2 parents 281ec36 + 01c7d48 commit 1aeb278
Show file tree
Hide file tree
Showing 4 changed files with 1,129 additions and 12 deletions.
27 changes: 26 additions & 1 deletion benchmarks/benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use criterion::{
Throughput,
};

use roaring::{MultiOps, RoaringBitmap};
use roaring::{MultiOps, RoaringBitmap, RoaringTreemap};

use crate::datasets::Datasets;

Expand Down Expand Up @@ -674,6 +674,30 @@ fn insert_range_bitmap(c: &mut Criterion) {
}
}

fn insert_range_treemap(c: &mut Criterion) {
for &size in &[1_000_u64, 10_000u64, 2 * (u32::MAX as u64)] {
let mut group = c.benchmark_group("insert_range_treemap");
group.throughput(criterion::Throughput::Elements(size as u64));
group.bench_function(format!("from_empty_{}", size), |b| {
let bm = RoaringTreemap::new();
b.iter_batched(
|| bm.clone(),
|mut bm| black_box(bm.insert_range(0..size)),
criterion::BatchSize::SmallInput,
)
});
group.bench_function(format!("pre_populated_{}", size), |b| {
let mut bm = RoaringTreemap::new();
bm.insert_range(0..size);
b.iter_batched(
|| bm.clone(),
|mut bm| black_box(bm.insert_range(0..size)),
criterion::BatchSize::SmallInput,
)
});
}
}

criterion_group!(
benches,
creation,
Expand All @@ -691,6 +715,7 @@ criterion_group!(
remove,
remove_range_bitmap,
insert_range_bitmap,
insert_range_treemap,
iteration,
is_empty,
serialization,
Expand Down
Loading

0 comments on commit 1aeb278

Please sign in to comment.