this is unnacceptably unperformant; I think I've reached the point at which sysinfo doesn't do what I want, which is keep track of a table of processes efficiently enough.
21 lines
593 B
Rust
21 lines
593 B
Rust
use std::{io::Write, thread};
|
|
|
|
use ron::{Error, ser};
|
|
|
|
use crate::sysinfo_snapshot::{self, SysinfoSnapshot};
|
|
|
|
pub fn run() -> Result<(), Error> {
|
|
let mut sys = sysinfo::System::new();
|
|
let refreshes = sysinfo_snapshot::refreshes();
|
|
|
|
sys.refresh_specifics(refreshes);
|
|
thread::sleep(sysinfo::MINIMUM_CPU_UPDATE_INTERVAL);
|
|
|
|
let mut stdout = std::io::stdout();
|
|
|
|
loop {
|
|
sys.refresh_specifics(refreshes);
|
|
stdout.write_all((ser::to_string(&SysinfoSnapshot::from(&sys))? + "\n").as_bytes())?;
|
|
thread::sleep(sysinfo::MINIMUM_CPU_UPDATE_INTERVAL);
|
|
}
|
|
}
|