Anonymous vs named settimeout in a loop (v3)

Revision 3 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Name function
for (i = 1; i <= 5; ++i) {
  setDelay(i);
}

function setDelay(i) {
  setTimeout(function(){
    console.log(i);
  }, 1000);
}
ready
Anonymous
var i = 1;
for (; i <= 5; ++i) {
    (function(n) {
        setTimeout(function(){
            console.log(n);
        }, 1000);
    }(i));
}
ready

Revisions

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