This article analyzes the performance graphs of Firefox, Safari, and Opera, and the graphs:
http://ejohn.org/blog/analyzing-timer-performance/
Firefox 2, Opera and Safari have a 10 ms bottom window for delays
For older browsers, you can run a test similar to the one in this article. I just checked the test I had with setInterval at setInterval intervals in IE6 and I got an average of 55ms. setTimeout seems 35 ms lower.
I ran a test in Chromium and got ~ 11 ms on average in 10 ms timeout. I tried it with an interval of 4 ms and 1 ms and got ~ 4.5 ms for both. Also, keep in mind that numbers may vary across operating systems.
If you're interested, here is the test code:
<script> // number of times to call setTimeout before calculating average var ITERATIONS = 200; window.onload = function() { testTimeout(10, +new Date, 0, 0); } // calls setTimeout repeatedly at a specified interval, tracking the amount // of time that passes between successive calls function testTimeout(interval, last, sum, ii) { var time = +new Date; var difference = time - last; sum += difference; if (ii % ITERATIONS == 1) { document.body.innerHTML = sum / ITERATIONS; sum = 0; } window.setTimeout( function() { testTimeout(interval, time, sum, ii + 1) }, interval); } </script>
Devourant Mar 10 2018-12-12T00: 00Z
source share