- Adds proper documentation comments with `# Errors` sections for all
functions returning `Result`
- `cast_precision_loss` on `u64` -> `f64` for disk sizes is acceptable
since disk sizes won't exceed f64's precision limit in practice.
Thus, we can suppress those.
- `cast_sign_loss` and `cast_possible_truncation` on the percentage
calculation is safe since percentages are always 0-100. Once again,
it's safe to suppress.
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Id4dd7ebc9674407d2be4f38ff4de24bc6a6a6964
It is difficult to get completely accurate benchmarks, given how small
the numbers we are dealing with are, but this seems to point at an
overall trend of *slightly* faster execution. The change minimizes
unnecessary memory allocations and string manipulations, to help ensure
more performant line reading and immediate return upon finding the
PRETTY_NAME without additional, redundant operations.
* perf: break early after parsing required meminfo
Also a match statement for compiler magic.
* perf: pre-allocate strings when reading files
* refactor: remove duplicate .to_string()
* perf: try to print everything in one syscall
println! sends a syscall for each line.
* perf: get rid of duplicate uname syscall
* perf: simplify first letter capitalization
* refactor: directly use key in match statement
Instead of reading multiple files to get the `sysname`, `release`, and
`machine` name, use the `nix::sys::utsname::uname` function which sends a
single uname syscall instead. This increases performance and portability.
From my observations, there are ~10 less syscalls.