/*
    Appellation: vstats <module>
    Contrib: @FL03
*/
/*
    Appellation: statistics <module>
    Contrib: @FL03
*/

/// Statistics about a memory optimization operation
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(
    feature = "serde",
    derive(serde_derive::Deserialize, serde_derive::Serialize)
)]
pub struct VirtualMemoryAnalysis<T = f32> {
    /// Number of features before optimization
    pub(crate) features_before: usize,
    /// Number of features after optimization
    pub(crate) features_after: usize,
    /// Number of features that were pruned
    pub(crate) pruned_count: usize,
    /// Memory pressure metric (ratio of features to target)
    pub(crate) memory_pressure: T,
    /// The importance threshold used for pruning
    pub(crate) importance_threshold: T,
}

impl<T> VirtualMemoryAnalysis<T> {
    pub fn new() -> Self
    where
        T: Default,
    {
        Self::default()
    }
    /// returns the number of features before optimization
    pub const fn features_before(&self) -> usize {
        self.features_before
    }
    /// returns a mutable reference to the number of features before optimization
    #[inline]
    pub fn features_before_mut(&mut self) -> &mut usize {
        &mut self.features_before
    }
    /// returns the number of features after optimization
    pub const fn features_after(&self) -> usize {
        self.features_after
    }
    /// returns a mutable reference to the number of features after optimization
    #[inline]
    pub fn features_after_mut(&mut self) -> &mut usize {
        &mut self.features_after
    }
    /// returns the number of features that were pruned
    pub const fn pruned_count(&self) -> usize {
        self.pruned_count
    }
    /// returns a mutable reference to the number of features that were pruned
    #[inline]
    pub fn pruned_count_mut(&mut self) -> &mut usize {
        &mut self.pruned_count
    }
    /// returns the memory pressure metric (ratio of features to target)
    pub const fn memory_pressure(&self) -> &T {
        &self.memory_pressure
    }
    /// returns a mutable reference to the memory pressure metric (ratio of features to target)
    #[inline]
    pub fn memory_pressure_mut(&mut self) -> &mut T {
        &mut self.memory_pressure
    }
    /// returns the importance threshold used for pruning
    pub const fn importance_threshold(&self) -> &T {
        &self.importance_threshold
    }
    /// returns a mutable reference to the importance threshold used for pruning
    #[inline]
    pub fn importance_threshold_mut(&mut self) -> &mut T {
        &mut self.importance_threshold
    }
}
