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

Precision tighter than milliseconds is problematic #42

Open
davedelong opened this issue Apr 12, 2020 · 2 comments
Open

Precision tighter than milliseconds is problematic #42

davedelong opened this issue Apr 12, 2020 · 2 comments

Comments

@davedelong
Copy link
Owner

It's difficult to deal with precision higher than milliseconds.

I'm attempting to write tests dealing with nanosecond precision and they're failing all over the place. Couple this with the face that DateFormatter won't format anything smaller than milliseconds and maybe Time should just cap things off there.

@akshayjshah
Copy link

Forgive me if I'm telling you stuff you already know, but...

Macs coalesce timers into 15ms windows to save power (and I assume iOS devices are even more aggressive). That makes writing tests for code dealing with smaller units of duration really hard. If you're running into trouble, you may want to try disabling coalescing: https://timoliver.blog/2014/01/25/disabling-timer-coalescing-in-os-x-mavericks/.

I've been bitten by this many times, and I forget this little nugget each time and waste hours debugging.

@davedelong
Copy link
Owner Author

Maybe a way to approach this could be having the system clocks pull their initial date via Date(), but then count and track intervals since then via a ContinuousClock, which would has higher precision than the milliseconds-by-default values coming out of Date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants