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.
Microfetch will now respect the NO_COLOR environment variable if it has
been passed to the program. The performance overhead of this operation
is almost none. In addition, the main function has been updated to lock
stdout.
* add benchmarking
* update README to include benchmarking of individual functions
* README: formatting
* README: add link to Criterion's getting_started
* shell.nix: add gnuplot
Since Criterion.rs uses gnuplot to generate nice plots, add it to the
shell.
* Cargo.toml: fixed microfetch binary name
* benchmark.rs: fix benchmark function's name
* Update README.md
---------
Co-authored-by: raf <raf@notashelf.dev>
* 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.