diff --git a/crates/nu-system/Cargo.toml b/crates/nu-system/Cargo.toml index cffef96b9e..7961f11ed2 100644 --- a/crates/nu-system/Cargo.toml +++ b/crates/nu-system/Cargo.toml @@ -27,8 +27,7 @@ which = "4" libc = "0.2" [target.'cfg(target_os = "windows")'.dependencies] -# winapi = { version = "0.3", features = ["handleapi", "minwindef", "psapi", "securitybaseapi", "tlhelp32", "winbase", "winnt"] } -winapi = { version = "0.3.9", features = ["tlhelp32", "fileapi", "handleapi", "ifdef", "ioapiset", "minwindef", "pdh", "psapi", "synchapi", "sysinfoapi", "winbase", "winerror", "winioctl", "winnt", "oleauto", "wbemcli", "rpcdce", "combaseapi", "objidl", "powerbase", "netioapi", "lmcons", "lmaccess", "lmapibuf", "memoryapi", "shellapi", "std"] } +winapi = { version = "0.3.9", features = ["tlhelp32", "fileapi", "handleapi", "ifdef", "ioapiset", "minwindef", "pdh", "psapi", "synchapi", "sysinfoapi", "winbase", "winerror", "winioctl", "winnt", "oleauto", "wbemcli", "rpcdce", "combaseapi", "objidl", "powerbase", "netioapi", "lmcons", "lmaccess", "lmapibuf", "memoryapi", "shellapi", "std", "securitybaseapi"] } chrono = "0.4" libc = "0.2" ntapi = "0.3" diff --git a/crates/nu-system/src/main.rs b/crates/nu-system/src/main.rs index f0ad96ee68..6c232fbc7e 100644 --- a/crates/nu-system/src/main.rs +++ b/crates/nu-system/src/main.rs @@ -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)); } }