2020-12-05 02:48:55 +00:00
|
|
|
//! `NcStats`
|
|
|
|
|
2021-06-15 19:00:52 +00:00
|
|
|
use crate::Nc;
|
2020-12-05 02:48:55 +00:00
|
|
|
|
|
|
|
/// notcurses runtime statistics
|
2020-12-05 17:55:10 +00:00
|
|
|
pub type NcStats = crate::bindings::ffi::ncstats;
|
2020-12-05 02:48:55 +00:00
|
|
|
|
|
|
|
/// # `NcStats` Methods.
|
|
|
|
impl NcStats {
|
|
|
|
/// Allocates an NcStats object.
|
2021-06-15 19:00:52 +00:00
|
|
|
pub fn new(nc: &mut Nc) -> &mut Self {
|
2020-12-05 02:48:55 +00:00
|
|
|
unsafe { &mut *crate::notcurses_stats_alloc(nc) }
|
|
|
|
}
|
|
|
|
|
2021-06-15 19:00:52 +00:00
|
|
|
/// Acquires an atomic snapshot of the notcurses object's stats.
|
|
|
|
pub fn stats(&mut self, nc: &mut Nc) {
|
2020-12-05 02:48:55 +00:00
|
|
|
unsafe { crate::notcurses_stats(nc, self) }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Resets all cumulative stats (immediate ones are not reset).
|
2021-06-15 19:00:52 +00:00
|
|
|
pub fn reset(&mut self, nc: &mut Nc) {
|
2020-12-05 02:48:55 +00:00
|
|
|
unsafe { crate::notcurses_stats_reset(nc, self) }
|
|
|
|
}
|
|
|
|
}
|