使用setInterval调度

   1:      var fireCount = 0;
   2:      var start = new Date;
   3:      var timer = setInterval(function() {
   4:        if (new Date - start > 1000) {
   5:   
   6:          clearInterval(timer)
   7:          console.log('setInterval 1000ms运行次数' + fireCount + "次数");
   8:          return
   9:        }
  10:        fireCount++;
  11:      }, 0)

1秒钟运行次数
Safari 224

深入理解javascript事件

Google Chrome 189

深入理解javascript事件

 

HTML规范,推行的延时/时间间隔的最小值是4毫秒

http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html

 

  • node中,pocess.nextTick 可以超过10万次/秒
  • requestAnimationFrame
      1. 允许60+帧/秒的速度运行动画

      2. 避免后台选项卡运行这些动画,节约CPU周期

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-01-04
  • 2022-02-11
  • 2021-05-30
  • 2022-12-23
  • 2021-12-10
猜你喜欢
  • 2021-05-07
  • 2022-12-23
  • 2021-07-04
  • 2022-12-23
  • 2021-06-27
  • 2021-11-30
相关资源
相似解决方案