foreach call vs prototype-call (v4)

Revision 4 of this benchmark created by Test on


Setup

var callbacks = [];
    for (var i = 0; i < 10; i++) {
      callbacks.push(function() { });
    }
    var call = Function.prototype.call;
    var length = callbacks.length;

Test runner

Ready to run.

Testing in
TestOps/sec
basic
callbacks.forEach(function(cb) {
  cb();
});
ready
Function.prototype.call
callbacks.forEach(Function.prototype.call, Function.prototype.call);
ready
Straight For Loop
for (var i = 0; i < callbacks.length; i++) {
            callbacks[i]();                
}
ready
Reference call property
callbacks.forEach(call, call);
ready
While loop
while (length > 0) {
    length--
    callbacks[length]();
}
ready

Revisions

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