#![allow(dead_code)]
use papaya::{HashMap, HashSet, ResizeMode};
use seize::Collector;
pub fn with_map<K, V>(mut test: impl FnMut(&dyn Fn() -> HashMap<K, V>)) {
let collector = || Collector::new().batch_size(128);
if !cfg!(papaya_stress) {
test(
&(|| {
HashMap::builder()
.collector(collector())
.resize_mode(ResizeMode::Blocking)
.build()
}),
);
}
test(
&(|| {
HashMap::builder()
.collector(collector())
.resize_mode(ResizeMode::Incremental(1))
.build()
}),
);
test(
&(|| {
HashMap::builder()
.collector(collector())
.resize_mode(ResizeMode::Incremental(128))
.build()
}),
);
}
pub fn with_set<K>(mut test: impl FnMut(&dyn Fn() -> HashSet<K>)) {
if !cfg!(papaya_stress) {
test(&(|| HashSet::builder().resize_mode(ResizeMode::Blocking).build()));
}
test(
&(|| {
HashSet::builder()
.resize_mode(ResizeMode::Incremental(1))
.build()
}),
);
test(
&(|| {
HashSet::builder()
.resize_mode(ResizeMode::Incremental(128))
.build()
}),
);
}
#[macro_export]
macro_rules! debug {
($($x:tt)*) => {
if std::env::var("RUST_LOG").as_deref() == Ok("debug") {
println!($($x)*);
}
};
}
pub fn threads() -> usize {
if cfg!(miri) {
2
} else {
num_cpus::get_physical().next_power_of_two()
}
}