What is minimum millisecond value of setTimeout?

前端 未结 4 1536
无人共我
无人共我 2020-11-22 13:28

I would like to put

var minValue = 0;
if ( typeof callback == \'function\' ) {
    setTimeout( callback, minValue );
}

this code when I imp

4条回答
  •  面向向阳花
    2020-11-22 14:07

    This article tests Firefox, Safari, and Opera and plots performance graphs:

    http://ejohn.org/blog/analyzing-timer-performance/

    Firefox 2, Opera, and Safari all have a bottom window of 10ms for delays

    For older browsers, you can do a test like the one in that article. I just ran a test that I had from a while ago of setInterval using a 10ms interval in IE6, and I got an average of 55ms. setTimeout seems to be lower at 35ms.

    I ran the test in Chromium and got ~11ms average for a 10ms timeout. I tried it with 4ms and 1ms intervals and got ~4.5ms for both. Also, keep in mind that the numbers could vary among operating systems.

    If you're interested, here's the test code:

    
    

提交回复
热议问题