//! Work counters for tests of lookup cost (feature `lookup-stats`). //! //! Counts fractal-heap objects read — each is one link or attribute message //! decoded out of a dense group or dense attribute storage — so a test can //! check that finding one name reads a handful of them, not the whole group. //! Per thread, so tests running in parallel do not see each other's reads. //! Without the feature the counting compiles to nothing. #[cfg(feature = "lookup-stats")] std::thread_local! { static HEAP_OBJECTS: core::cell::Cell = const { core::cell::Cell::new(0) }; } /// Record one heap object read. #[inline(always)] pub(crate) fn heap_object_read() { #[cfg(feature = "lookup-stats")] HEAP_OBJECTS.with(|c| c.set(c.get() + 1)); } /// Heap objects read on this thread since the last [`reset`]. #[cfg(feature = "lookup-stats")] pub fn heap_objects_read() -> u64 { HEAP_OBJECTS.with(core::cell::Cell::get) } /// Zero this thread's counters. #[cfg(feature = "lookup-stats")] pub fn reset() { HEAP_OBJECTS.with(|c| c.set(0)); }