mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 06:30:08 +02:00
Make example binaries proper cargo examples (#7019)
Should not be built by default with `cargo build` Instead are compiled with `cargo test` to avoid bitrot Run with `cargo run -p ... --example ...`
This commit is contained in:
committed by
GitHub
parent
5ee7847035
commit
5ea245badf
32
crates/nu-system/examples/demo.rs
Normal file
32
crates/nu-system/examples/demo.rs
Normal file
@ -0,0 +1,32 @@
|
||||
fn main() {
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "windows"
|
||||
))]
|
||||
{
|
||||
let cores = match std::thread::available_parallelism() {
|
||||
Ok(p) => p.get(),
|
||||
Err(_) => 1usize,
|
||||
};
|
||||
for run in 1..=10 {
|
||||
for proc in nu_system::collect_proc(std::time::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));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user