This commit is contained in:
Twan Stok 2023-03-13 03:37:30 +01:00
parent 1c3bfdb0f9
commit 4afd71926f
3 changed files with 13 additions and 4 deletions

View File

@ -212,7 +212,11 @@ impl DataCollection {
}
// Memory and Swap
if let (Some(memory), Some(cache), Some(swap)) = (harvested_data.memory, harvested_data.cache, harvested_data.swap) {
if let (Some(memory), Some(cache), Some(swap)) = (
harvested_data.memory,
harvested_data.cache,
harvested_data.swap,
) {
self.eat_memory_and_swap(memory, cache, swap, &mut new_entry);
}
@ -267,7 +271,8 @@ impl DataCollection {
}
fn eat_memory_and_swap(
&mut self, memory: memory::MemHarvest, cache: memory::MemHarvest, swap: memory::MemHarvest, new_entry: &mut TimedData,
&mut self, memory: memory::MemHarvest, cache: memory::MemHarvest, swap: memory::MemHarvest,
new_entry: &mut TimedData,
) {
// Memory
new_entry.mem_data = memory.use_percent;

View File

@ -1,8 +1,8 @@
//! Memory data collection.
pub mod sysinfo;
pub(crate) use self::sysinfo::get_ram_usage;
pub(crate) use self::sysinfo::get_cache_usage;
pub(crate) use self::sysinfo::get_ram_usage;
cfg_if::cfg_if! {
if #[cfg(target_os = "windows")] {

View File

@ -258,7 +258,11 @@ pub fn convert_swap_data_points(current_data: &DataCollection) -> Vec<Point> {
pub fn convert_mem_labels(
current_data: &DataCollection,
) -> (Option<(String, String)>, Option<(String, String)>, Option<(String, String)>) {
) -> (
Option<(String, String)>,
Option<(String, String)>,
Option<(String, String)>,
) {
/// Returns the unit type and denominator for given total amount of memory in kibibytes.
fn return_unit_and_denominator_for_mem_kib(mem_total_kib: u64) -> (&'static str, f64) {
if mem_total_kib < 1024 {