use std::cell::RefCell;
use std::collections::HashMap;
pub mod buckets {
pub const IMAGE_EDGES: &str = "image_edges";
pub const CAT_EDGES: &str = "cat_edges";
pub const KEY_ENUM: &str = "key_enum";
pub const SVD: &str = "svd";
pub const VERIFY_QUERY: &str = "verify_query";
pub const VERIFY_MATCH: &str = "verify_match";
pub const WCS_REFINE: &str = "wcs_refine";
pub const FOV_PASS: &str = "fov_pass";
pub const COMBOS: &str = "combos";
pub const CANDIDATES: &str = "candidates";
pub const RATIO_PASS: &str = "ratio_pass";
pub const VERIFY_QUERY_STARS: &str = "verify_query_stars";
pub const WCS_OUTER: &str = "wcs_outer";
pub const WCS_INNER: &str = "wcs_inner";
pub const WCS_RADEC: &str = "wcs_radec";
pub const WCS_REASSOC_QUERY: &str = "wcs_reassoc_query";
pub const WCS_REASSOC_PROJECT: &str = "wcs_reassoc_project";
pub const WCS_REASSOC_MATCH: &str = "wcs_reassoc_match";
pub const WCS_REASSOC_CALL: &str = "wcs_reassoc_call";
pub const WCS_REASSOC_STARS: &str = "wcs_reassoc_stars";
}
thread_local! {
static ACC: RefCell<HashMap<&'static str, (u128, u64)>> = RefCell::new(HashMap::new());
}
pub fn record(bucket: &'static str, ns: u128, count: u64) {
ACC.with(|a| {
let mut m = a.borrow_mut();
let e = m.entry(bucket).or_insert((0, 0));
e.0 += ns;
e.1 += count;
});
}
pub fn count(bucket: &'static str, n: u64) {
record(bucket, 0, n);
}
pub fn reset() {
ACC.with(|a| a.borrow_mut().clear());
}
pub fn snapshot() -> Vec<(&'static str, u128, u64)> {
ACC.with(|a| a.borrow().iter().map(|(k, v)| (*k, v.0, v.1)).collect())
}