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

fix: switch to clock_gettime(3) for macOS/iOS for monotonic clock #97

Merged
merged 2 commits into from
Dec 31, 2023

Conversation

tobz
Copy link
Member

@tobz tobz commented Dec 31, 2023

This fixes an issue where on M1 (and presumably M2/M3) hardware, the usage of mach_absolute_time() resulted in undermeasuring the passage of time when compared to std::time::Instant.

Now we read from the monotonic clock (using clock_gettime(CLOCK_MONOTONIC), but conceptually the same as calling mach_continuous_time()) which properly tracks the passage of time regardless of device sleep, frequency, etc.

Fixes #96.

This fixes an issue where on M1 (and presumably M2/M3) hardware,
the usage of mach_absolute_time() resulted in undermeasuring the
passage of time when compared to std::time::Instant. Now we read
from the monotonic clock (using clock_gettime, but conceptually
the same as calling mach_continuous_time()) which properly tracks
the passage of time regardless of device sleep, frequency, etc.
@tobz tobz enabled auto-merge (squash) December 31, 2023 16:00
@tobz tobz disabled auto-merge December 31, 2023 16:01
@tobz tobz merged commit 0e6d83d into main Dec 31, 2023
30 checks passed
@tobz tobz deleted the tobz/fix-macos-monotonic-clock branch December 31, 2023 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant