foreach call vs prototype-call (v10)

Revision 10 of this benchmark created by rajiv on


Setup

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

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
while
var i = 0,
  len = callbacks.length;
while (i < len) {
  callbacks[i]();
  i += 1;
}
ready
for
for (var i = 0, l = callbacks.length; i < l; i += 1) {
  callbacks[i]();
}
ready
backwards while
var i = callbacks.length;
while (i > 0)
  callbacks[--i]();
ready

Revisions

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