commonware-utils 2026.5.0

Leverage common functionality across multiple primitives.
Documentation
use commonware_utils::bitmap::roaring::Bitmap;
use criterion::{criterion_group, Criterion};
use roaring::RoaringTreemap;
use std::hint::black_box;

fn benchmark_difference(c: &mut Criterion) {
    let mut group = c.benchmark_group(module_path!());
    for count in [1000, 10000] {
        let mut ours_a = Bitmap::new();
        let mut ours_b = Bitmap::new();
        let mut theirs_a = RoaringTreemap::new();
        let mut theirs_b = RoaringTreemap::new();

        for i in 0..count {
            ours_a.insert(i * 2);
            ours_b.insert(i * 3);
            theirs_a.insert(i * 2);
            theirs_b.insert(i * 3);
        }

        group.bench_function(format!("count={count} impl=ours"), |b| {
            b.iter(|| black_box(ours_a.difference(&ours_b, u64::MAX)));
        });

        group.bench_function(format!("count={count} impl=roaring-rs"), |b| {
            b.iter(|| black_box(&theirs_a - &theirs_b));
        });
    }
    group.finish();
}

criterion_group! {
    name = benches;
    config = Criterion::default().sample_size(50);
    targets = benchmark_difference,
}