pub trait CpuExt: Debug {
fn cpu_usage(&self) -> f32;
fn name(&self) -> &str;
fn vendor_id(&self) -> &str;
fn brand(&self) -> &str;
fn frequency(&self) -> u64;
}
Expand description
Contains all the methods of the Cpu
struct.
Required Methods
Returns this CPU’s usage.
Note: You’ll need to refresh it at least twice (diff between the first and the second is how CPU usage is computed) at first if you want to have a non-zero value.
use sysinfo::{CpuExt, System, SystemExt};
let s = System::new();
for cpu in s.cpus() {
println!("{}%", cpu.cpu_usage());
}
Returns this CPU’s name.
use sysinfo::{CpuExt, System, SystemExt};
let s = System::new();
for cpu in s.cpus() {
println!("{}", cpu.name());
}
Returns the CPU’s vendor id.
use sysinfo::{CpuExt, System, SystemExt};
let s = System::new();
for cpu in s.cpus() {
println!("{}", cpu.vendor_id());
}
Returns the CPU’s brand.
use sysinfo::{CpuExt, System, SystemExt};
let s = System::new();
for cpu in s.cpus() {
println!("{}", cpu.brand());
}