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

JavaScript timing calculations could be more precise #106

Open
JohnRiv opened this issue Nov 22, 2017 · 0 comments
Open

JavaScript timing calculations could be more precise #106

JohnRiv opened this issue Nov 22, 2017 · 0 comments

Comments

@JohnRiv
Copy link
Member

JohnRiv commented Nov 22, 2017

All of the timing calculations appear to only leverage Date.now()... It would be better to use User Timing and/or Resource Timing if the user's browser supports it, or High Resolution Timing if neither is supported. Reason being is if a system clock adjustment happens to occur when doing the timing, the results will be inaccurate. Plus those other APIs provide sub-millisecond timing data.

Only if High Resolution timing is not supported should you fall back to Date.now().

Surf-N-Perf can help streamline that for you if you want to simplify your code, and that supports older browsers that don't support Date.now() as well.

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

No branches or pull requests

1 participant