zoukankan      html  css  js  c++  java
  • 深入理解javascript事件

    使用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

    image

    Google Chrome 189

    image

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

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

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

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

  • 相关阅读:
    POJ 1401 Factorial
    POJ 2407 Relatives(欧拉函数)
    POJ 1730 Perfect Pth Powers(唯一分解定理)
    POJ 2262 Goldbach's Conjecture(Eratosthenes筛法)
    POJ 2551 Ones
    POJ 1163 The Triangle
    POJ 3356 AGTC
    POJ 2192 Zipper
    POJ 1080 Human Gene Functions
    POJ 1159 Palindrome(最长公共子序列)
  • 原文地址:https://www.cnblogs.com/aaronjs/p/3158474.html
Copyright © 2011-2022 走看看