#![allow(dead_code)]
use std::sync::LazyLock;
use std::sync::atomic::{AtomicU64, Ordering};
#[derive(Default)]
pub struct FrameMetrics {
last_bytes: AtomicU64,
total_frames: AtomicU64,
}
impl FrameMetrics {
pub fn record_cell_frame_bytes(&self, bytes: usize) {
self.last_bytes.store(bytes as u64, Ordering::Relaxed);
self.total_frames.fetch_add(1, Ordering::Relaxed);
}
pub fn last_bytes(&self) -> u64 {
self.last_bytes.load(Ordering::Relaxed)
}
pub fn total_frames(&self) -> u64 {
self.total_frames.load(Ordering::Relaxed)
}
}
static METRICS: LazyLock<FrameMetrics> = LazyLock::new(FrameMetrics::default);
pub fn record_cell_frame_bytes(bytes: usize) {
METRICS.record_cell_frame_bytes(bytes);
}
pub fn last_cell_frame_bytes() -> u64 {
METRICS.last_bytes()
}
pub fn total_cell_frames() -> u64 {
METRICS.total_frames()
}