临时笔记

控制台测试帧率

// 在控制台执行,查看帧率
(function() {
  let frameCount = 0;
  let lastTime = performance.now();
  
  function countFrames() {
    frameCount++;
    const now = performance.now();
    if (now - lastTime >= 1000) {
      console.log(`FPS: ${frameCount}`);
      frameCount = 0;
      lastTime = now;
    }
    requestAnimationFrame(countFrames);
  }
  
  countFrames();
})();

浏览器控制台输入这行代码可以直接编辑页面内容

document.body.contentEditable = true

alwaysdata