Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try hoisting out the timebase_to_ns #959

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/apple/macos/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ 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;
base_interval.max(smallest) / self.timebase_to_ns
}
}
}