-
Notifications
You must be signed in to change notification settings - Fork 116
Description
The basic idea behind the useHardwareConcurrency hook is great, but I fear that it is not sufficient to identify slow devices.
Even the moto G of the first generation (with a Snapdragon 400 CPU) has 4 cores. On the other hand, older iPhones only have 2 cores while the single cores are much faster and are able to run expensive animations more easily compared to low end android devices with more cores.
Could we maybe implement a "mini benchmark" to identify the JS execution speed of the device?
Maybe something along the lines of this:
function measure() {
let start = Date.now();
let index = 0;
while (start + 8 >= Date.now()) index++;
return index;
}
This would however block the mainthread for 8ms (duration could be changed obviously).
Get your score here: https://ogb5i.csb.app/
My Laptop (i7 8565U) manages something around 30.000 while my s10 (Exynos variant) only gets 3.000 - 10.000, the s7 of a friend manages ~1000 and the iPhone 6s of a friend gets 8.000
One would need to source the scores for different devices and implement categories.
Another added benefit would be, that the JS execution speed of the browser is factored in. That would mean, that IE gets fewer heavy animations because it is slower.