Crates.io | command-rusage |
lib.rs | command-rusage |
version | 1.0.1 |
source | src |
created_at | 2023-10-09 19:13:33.781291 |
updated_at | 2023-10-09 19:18:29.527968 |
description | Simple crate to get resource usage of a command |
homepage | |
repository | |
max_upload_size | |
id | 998360 |
size | 6,006 |
Simple wrapper for linux wait4
syscall to get resource usage of a child process. This allows to measure multiple parameters of a child process, including CPU user/system times, memory usage, number of page faults, etc.
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());