2个稳定版本
1.0.1 | 2023年10月9日 |
---|
#590 in Unix APIs
6KB
100 行代码(不包括注释)
command-rusage
一个简单的Linux wait4
系统调用的包装器,用于获取子进程的资源使用情况。这允许测量子进程的多个参数,包括CPU用户/系统时间、内存使用量、页面错误数等。
使用方法
use command_rusage::GetRUsage;
use std::process::Command;
let mut child = Command::new("sleep").arg("1").spawn().unwrap();
let rusage = child.wait_for_rusage().unwrap();
println!("User time: {}s", rusage.utime.as_secs_f64());
依赖项
~43KB