A small Rust library to get memory usage and elapsed CPU time.
tokio::fs
for file operations```rust use simpleprocessstats::ProcessStats;
let processstats = ProcessStats::get().expect("could not get stats for running process"); println!("{:?}", processstats); // ProcessStats { // cputimeuser: 421.875ms, // cputimekernel: 102.332ms, // memoryusagebytes: 3420160, // } ```
On Linux, this library reads /proc/self/stat
and uses the sysconf
libc function.
On Windows, the library uses GetCurrentProcess
combined with GetProcessTimes
and K32GetProcessMemoryInfo
.