use super::{IoStats, IoStatsSnapshot};
use std::sync::Arc;
#[derive(Debug)]
pub struct PagerDiagnostics {
stats: Arc<IoStats>,
run_start: IoStatsSnapshot,
}
impl PagerDiagnostics {
pub fn new(stats: Arc<IoStats>) -> Self {
let run_start = stats.snapshot();
Self { stats, run_start }
}
pub fn snapshot(&self) -> IoStatsSnapshot {
self.stats.snapshot()
}
pub fn totals(&self) -> IoStatsSnapshot {
self.snapshot().delta_since(&self.run_start)
}
pub fn delta_since(&self, older: &IoStatsSnapshot) -> IoStatsSnapshot {
self.snapshot().delta_since(older)
}
pub fn stats(&self) -> Arc<IoStats> {
Arc::clone(&self.stats)
}
}