Skip to content

jeremy-prater/simple-process-stats

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-process-stats

A small library to get memory usage and elapsed CPU time.

  • Supports Windows, Linux and macOS.
  • Async interface, uses tokio::fs for file operations
use 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).

About

A small Rust library to get memory usage and elapsed CPU time.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%