sys_demo/
sys_demo.rs

1fn main() {
2    #[cfg(any(
3        target_os = "android",
4        target_os = "linux",
5        target_os = "macos",
6        target_os = "windows"
7    ))]
8    {
9        let cores = std::thread::available_parallelism()
10            .map(|p| p.get())
11            .unwrap_or(1);
12        for run in 1..=10 {
13            for proc in nu_system::collect_proc(std::time::Duration::from_millis(100), false) {
14                if proc.cpu_usage() > 0.00001 {
15                    println!(
16                        "{} - {} - {} - {} - {:.2}% - {}M - {}M - {} procs",
17                        run,
18                        proc.pid(),
19                        proc.name(),
20                        proc.status(),
21                        proc.cpu_usage() / cores as f64,
22                        proc.mem_size() / (1024 * 1024),
23                        proc.virtual_size() / (1024 * 1024),
24                        cores,
25                    )
26                }
27            }
28            std::thread::sleep(std::time::Duration::from_millis(1000));
29        }
30    }
31}