Skip to content

Commit

Permalink
hoist out timebase_to_ns in process interval calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementTsang committed Mar 24, 2023
1 parent 8ade504 commit e8fc7cb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/apple/macos/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,14 @@ impl SystemTimeInfo {

// Now we convert the ticks to nanoseconds (if the interval is less than
// `MINIMUM_CPU_UPDATE_INTERVAL`, we replace it with it instead):
(total as f64 / self.timebase_to_ns * self.clock_per_sec / cpu_count as f64)
.max(crate::System::MINIMUM_CPU_UPDATE_INTERVAL.as_secs_f64() * 1_000_000_000.)
let base_interval = total as f64 / cpu_count as f64 * self.clock_per_sec;
let smallest =
crate::System::MINIMUM_CPU_UPDATE_INTERVAL.as_secs_f64() * 1_000_000_000.0;
if base_interval < smallest {
smallest
} else {
base_interval / self.timebase_to_ns
}
}
}
}

0 comments on commit e8fc7cb

Please sign in to comment.