vor 0.2.1

Cross-platform performance instrumentation with an in-app egui panel and live system and GPU metrics.
Documentation
/// Resident memory in bytes for the current process.
///
/// - With feature `mac`: OS-reported physical memory from `memory-stats`.
/// - With feature `web`: `performance.memory.usedJSHeapSize` from
///   Chromium. Firefox and Safari return `None` (they don't expose
///   the non-standard `performance.memory` object).
/// - Otherwise: `None`.
#[cfg(feature = "mac")]
pub fn current_memory_bytes() -> Option<u64> {
    memory_stats::memory_stats().map(|s| s.physical_mem as u64)
}

#[cfg(all(feature = "web", not(feature = "mac")))]
pub fn current_memory_bytes() -> Option<u64> {
    let perf = web_sys::window()?.performance()?;
    let memory = js_sys::Reflect::get(perf.as_ref(), &"memory".into()).unwrap();
    if memory.is_undefined() || memory.is_null() {
        return None;
    }
    let used = js_sys::Reflect::get(&memory, &"usedJSHeapSize".into()).unwrap();
    used.as_f64().map(|v| v as u64)
}

#[cfg(not(any(feature = "mac", feature = "web")))]
pub const fn current_memory_bytes() -> Option<u64> {
    None
}