Cached Callbacks (500 thousand) (v2)

Revision 2 of this benchmark created by brycebaril on


Setup

var bigList = [];
    var n = Math.pow(10, 6) / 2; // 500k items
    for (var i=0; i<n; i++) {
      bigList.push('item number ' + i);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
for loop (500k)
var newList = [];
for (var i=0; i<bigList.length; i++) {
  newList.push(bigList[i] + ' mapped');
}
ready
map, anon (500k)
var newList = bigList.map(function (item) {
  return item + ' mapped';
});
ready
map, cached (500k)
var add1 = function (item) {
  return item + ' mapped';
};

var newList = bigList.map(add1);
ready
for loop with hint (500k)
var newList = new Array(bigList.length);
for (var i=0; i<bigList.length; i++) {
  newList[i] = bigList[i] + " mapped";
}
ready

Revisions

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

  • Revision 1: published by rhodesjason on
  • Revision 2: published by brycebaril on