nushell/crates/nu-system/src/main.rs
2022-03-17 11:32:54 -05:00

28 lines
866 B
Rust

use std::thread::available_parallelism;
use std::time::Duration;
fn main() {
let cores = match available_parallelism() {
Ok(p) => p.get(),
Err(_) => 1usize,
};
for run in 1..=10 {
for proc in nu_system::collect_proc(Duration::from_millis(100), false) {
if proc.cpu_usage() > 0.00001 {
println!(
"{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
run,
proc.pid(),
proc.name(),
proc.status(),
proc.cpu_usage() / cores as f64,
proc.mem_size() / (1024 * 1024),
proc.virtual_size() / (1024 * 1024),
cores,
)
}
}
std::thread::sleep(std::time::Duration::from_millis(1000));
}
}