command-rusage

Crates.iocommand-rusage
lib.rscommand-rusage
version1.0.1
sourcesrc
created_at2023-10-09 19:13:33.781291
updated_at2023-10-09 19:18:29.527968
descriptionSimple crate to get resource usage of a command
homepage
repository
max_upload_size
id998360
size6,006
olix3001 (olix3001)

documentation

README

command-rusage

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.

Usage

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());
Commit count: 0

cargo fmt