Leave a Comment
Simple way to detect browser’s FPS via JS
It’s dumb and dead simple but works.
You can even track browser’s metrics with that.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
(() => { const times = []; let fps; function refreshLoop() { window.requestAnimationFrame(() => { const now = performance.now(); while (times.length > 0 && times[0] <= now - 1000) { times.shift(); } times.push(now); fps = times.length; refreshLoop(); }); } refreshLoop(); // output to console once per second setInterval(() => {console.log(fps);}, 1000) })(); |
Similar Posts
LEAVE A COMMENT
Для отправки комментария вам необходимо авторизоваться.