native map vs underscore map vs for loop (v2)

Revision 2 of this benchmark created by john remmen on


Preparation HTML

<script src="https://documentcloud.github.com/underscore/underscore-min.js"></script>

Setup

arr = [1, 2, 3, 4, 5];

Test runner

Ready to run.

Testing in
TestOps/sec
Native map
arr.map(function(entry) {
  return entry + 1;
});
ready
Undescore map
_.map(arr, function(entry) {
  return entry + 1;
});
ready
for loop
for(var i = 0, l = arr.length; i < l; i += 1) {
   arr[i] += 1;
}
ready

Revisions

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