3 ms·
1. Pick the API that's most likely to be the fastest (based on marketshare) as the default to use. 2. Use `setInterval` to start your benchmark routine. 3. Be
by vlovich123 4y ago
1. Pick the API that's most likely to be the fastest (based on marketshare) as the default to use.
2. Use `setInterval` to start your benchmark routine.
3. Benchmark function runs the API using a simple loop that will return quickly (i.e. within 2ms) using performance.now to evaluate.
4. When you obtain enough samples to indicate an alternate path is faster disable the benchmark function
No freezing the browser. Shouldn't take too long to switch to an optimized version.
That being said, this is a lot of complexity / hard to implement in a robust and fast way so I'm not saying it's a better answer.
- madeofpalk 4y agoYeah or just test the user agent.