| 1 | //! Memory data collection. |
| 2 | |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::NonZeroU64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU64#; |
| 4 | |
| 5 | pub(craterust-analyzer cargo bottom 0.14.9 crate/) use selfrust-analyzer cargo bottom 0.14.9 collection/memory/::sysinforust-analyzer cargo bottom 0.14.9 collection/memory/sysinfo/::get_ram_usagerust-analyzer cargo bottom 0.14.9 collection/memory/sysinfo/get_ram_usage().; |
| 6 | |
| 7 | pub mod sysinforust-analyzer cargo bottom 0.14.9 collection/memory/sysinfo/; |
| 8 | |
| 9 | cfg_selectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/cfg_select!! { |
| 10 | target_os = "windows" => { |
| 11 | mod windows; |
| 12 | pub(crate) use self::windows::get_swap_usage; |
| 13 | } |
| 14 | _ => { |
| 15 | pub(craterust-analyzer cargo bottom 0.14.9 crate/) use selfrust-analyzer cargo bottom 0.14.9 collection/memory/::sysinforust-analyzer cargo bottom 0.14.9 collection/memory/sysinfo/::{get_cache_usagerust-analyzer cargo bottom 0.14.9 collection/memory/sysinfo/get_cache_usage()., get_swap_usagerust-analyzer cargo bottom 0.14.9 collection/memory/sysinfo/get_swap_usage().}; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | #[cfg(feature = "zfs")] |
| 20 | pub mod arcrust-analyzer cargo bottom 0.14.9 collection/memory/arc/; |
| 21 | |
| 22 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 23 | pub struct MemDatarust-analyzer cargo bottom 0.14.9 collection/memory/MemData# { |
| 24 | pub used_bytesrust-analyzer cargo bottom 0.14.9 collection/memory/MemData#used_bytes.: u64, |
| 25 | pub total_bytesrust-analyzer cargo bottom 0.14.9 collection/memory/MemData#total_bytes.: NonZeroU64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU64#, |
| 26 | } |
| 27 | |
| 28 | impl MemDatarust-analyzer cargo bottom 0.14.9 collection/memory/MemData# { |
| 29 | /// Return the use percentage. |
| 30 | #[inline] |
| 31 | pub fn percentagerust-analyzer cargo bottom 0.14.9 collection/memory/impl#[MemData]percentage().(&self) -> f64 { |
| 32 | let used = self.used_bytesrust-analyzer cargo bottom 0.14.9 collection/memory/MemData#used_bytes. as f64; |
| 33 | let total = self.total_bytesrust-analyzer cargo bottom 0.14.9 collection/memory/MemData#total_bytes..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().() as f64; |
| 34 | |
| 35 | used rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().total rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().100.0 |
| 36 | } |
| 37 | } |