I was reviewing some older elm-dev threads today when I revisited the following:
https://groups.google.com/forum/m/#!topic/elm-dev/n9Kv9WDMo4E
I got to playing with performance.now() some more and realized that there is actually a notable difference between the normalized result it gives and the one from Date.now() that can range from 10ms to almost half a second depending on the number of calls that have already been made to either function. It seems this stems from performance.now() reading from a separate clock than Date.now().
The immediate issue is that elm-lang/animation-frame, which uses high-res timestamps, is supposed to be designed so that timestamps are correct when used against Time.now, but like I said, they will be off be at least a small number of milliseconds.
This can be fixed by standardizing on one source of timestamps for all time-based effects. I'd like to propose that source be performance.now() when available with a fallback to Date.now(). This could be made simple to manage in code by writing a currentTime() function in Native.Time that abstracts that decision in a consistent way for all other packages.
The benefit to doing this is that Elm can guarantee that all timestamps are the most precise that the platform can offer. This could make Time.now a sufficient tool for building benchmarking packages and tools entirely in Elm so that they can be published on the package registry.
I'm happy to write these changes and submit a PR, as always.
To sumarrize,
Do:
- Add a function to Native.Time to get current time from performance.now() and fall back to Date.now()
- Use it wherever timestamps are needed in elm-lang/* packages
Get:
- A bug in animation-frame gets fixed
- People can start experimenting with benchmarking tools in pure Elm
--
You received this message because you are subscribed to the Google Groups "elm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elm-dev/9703a362-9d10-4178-a344-8a51e53d9061%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elm-dev/a6fb9968-4163-4711-b0f1-ea8bf2912446%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+unsubscribe@googlegroups.com.