some tweaks to main for testing (#4862)

This commit is contained in:
Darren Schroeder
2022-03-17 11:32:54 -05:00
committed by GitHub
parent 9db356e174
commit 6e69d40bb9
2 changed files with 23 additions and 14 deletions

View File

@ -1,17 +1,27 @@
use std::thread::available_parallelism;
use std::time::Duration;
fn main() {
for proc in nu_system::collect_proc(Duration::from_millis(100), false) {
// if proc.cpu_usage() > 0.1 {
println!(
"{} - {} - {} - {:.1} - {}M - {}M",
proc.pid(),
proc.name(),
proc.status(),
proc.cpu_usage(),
proc.mem_size() / (1024 * 1024),
proc.virtual_size() / (1024 * 1024),
)
// }
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));
}
}