Skip to content

Commit

Permalink
Use SystemExt::MINIMUM_CPU_UPDATE_INTERVAL more often
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jul 21, 2023
1 parent 0aff79a commit e8f40f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ loop {
for cpu in sys.cpus() {
print!("{}% ", cpu.cpu_usage());
}
// Sleeping for 500 ms to let time for the system to run for long
// Sleeping to let time for the system to run for long
// enough to have useful information.
std::thread::sleep(std::time::Duration::from_millis(500));
std::thread::sleep(System::MINIMUM_CPU_UPDATE_INTERVAL);
}
```

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ mod test {
.all(|(_, proc_)| proc_.cpu_usage() == 0.0));

// Wait a bit to update CPU usage values
std::thread::sleep(std::time::Duration::from_millis(100));
std::thread::sleep(System::MINIMUM_CPU_UPDATE_INTERVAL);
s.refresh_processes();
assert!(s
.processes()
Expand All @@ -297,7 +297,7 @@ mod test {
for _ in 0..10 {
s.refresh_cpu();
// Wait a bit to update CPU usage values
std::thread::sleep(std::time::Duration::from_millis(100));
std::thread::sleep(System::MINIMUM_CPU_UPDATE_INTERVAL);
if s.cpus().iter().any(|c| c.cpu_usage() > 0.0) {
// All good!
return;
Expand Down

0 comments on commit e8f40f4

Please sign in to comment.