setTimeout vs. setInterval (v4)

Revision 4 of this benchmark created on


Preparation HTML

<script>
  window.foo = 'qux';
  
  function test1() {
    window.foo = 'bar';
  }
  
  function test2() {
    var i = 1000;
    while (i--) {
      window.foo = 'bar';
    }
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
setTimeout + fast function
setTimeout(test1, 0);
ready
setTimeout + slow function
setTimeout(test2, 0);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.