bfree 0.1.14

bfree - memory stats for humans
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::core::memory_stats::MemoryStats;
use crate::render::format::fmt_short;

/// Default one-line output (no colors, no styling).
///
/// Example:
/// Mem used 7.2GiB / 16GiB (45%) | Swap used 0.1GiB / 2GiB (5%)
pub fn render(s: &MemoryStats) -> String {
    format!(
        "Mem used {} / {} ({:.0}%) | Swap used {} / {} ({:.0}%)",
        fmt_short(s.mem_used()),
        fmt_short(s.mem_total),
        s.mem_used_percent(),
        fmt_short(s.swap_used()),
        fmt_short(s.swap_total),
        s.swap_used_percent(),
    )
}