Use Performance API for high-precision time on JS#2895
Conversation
|
One learning from this PR is that |
|
Urgh, extremely annoying! On browsers |
|
Hmm, even with the Update: the problem is with Node 14. Hmmm. |
This reverts commit 6ae23ee.
|
Node 14 is LTS for one more year. I guess we should keep it in CI :( |
| private[this] val nowMicrosImpl: () => Long = { | ||
| def test(performance: Performance): Try[Performance] = Try { | ||
| // take it for a spin | ||
| require(!(performance.timeOrigin + performance.now()).isNaN) |
There was a problem hiding this comment.
Exceptions are pretty expensive. Can we turn this into a simple if/else?
There was a problem hiding this comment.
Even for a one-time initialization?
There was a problem hiding this comment.
Yeah, you're probably right :( I've used Try in many places, maybe I should dial those back.
|
This is looking to be flaky on Chrome. Unfortunately the resolution there is 100 microseconds (versus 5 microseconds on Firefox with |
|
@armanbilge This is ready to go once the conflicts are resolved. |
Follow-up to #2416.
Always an adventure on JS :) there's nothing in the ES standard, but amazingly both browsers and Node.js have implemented the same APIs for once! With of course the caveat that for whatever reason
performance.timeOriginis "experimental technology" on the web 🙃