| Crates.io | simple-process-stats |
| lib.rs | simple-process-stats |
| version | 1.0.0 |
| created_at | 2020-07-19 18:01:37.460442+00 |
| updated_at | 2020-12-25 19:31:57.820301+00 |
| description | Get memory usage and CPU time on Linux and Windows |
| homepage | |
| repository | https://github.com/robotty/simple-process-stats |
| max_upload_size | |
| id | 266952 |
| size | 16,219 |
A small library to get memory usage and elapsed CPU time.
tokio::fs for file operationsuse simple_process_stats::ProcessStats;
let process_stats = ProcessStats::get().await.expect("could not get stats for running process");
println!("{:?}", process_stats);
// ProcessStats {
// cpu_time_user: 421.875ms,
// cpu_time_kernel: 102.332ms,
// memory_usage_bytes: 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.
On macOS, this library uses proc_pidinfo from libproc (and current process ID is determined via libc).