vor 0.2.0

Cross-platform performance instrumentation with an in-app egui panel and live system and GPU metrics.
Documentation
use std::sync::atomic::{AtomicU64, Ordering};

static IO_NS: AtomicU64 = AtomicU64::new(0);
static IO_BYTES: AtomicU64 = AtomicU64::new(0);

/// Snapshot of one frame's I/O totals.
#[derive(Clone, Copy)]
pub struct IoTick {
    pub elapsed_ns: u64,
    pub bytes: u64,
}

/// Add one I/O event to the current frame's totals.
///
/// Cheap (two relaxed atomic adds); safe to call from any thread,
/// including background streaming workers.
pub fn record(elapsed_ns: u64, bytes: u64) {
    IO_NS.fetch_add(elapsed_ns, Ordering::Relaxed);
    IO_BYTES.fetch_add(bytes, Ordering::Relaxed);
}

/// Read + reset the I/O accumulator. Call once per rendered frame
/// (after [`frame_mark`](crate::frame_mark)) so the next frame's
/// totals start from zero.
pub fn drain() -> IoTick {
    IoTick {
        elapsed_ns: IO_NS.swap(0, Ordering::Relaxed),
        bytes: IO_BYTES.swap(0, Ordering::Relaxed),
    }
}