push vs map and concat

Benchmark created on


Preparation HTML

<script src="http://underscorejs.org/underscore-min.js"></script>

Setup

var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
    var result = [];

Test runner

Ready to run.

Testing in
TestOps/sec
push
for (var i = 0; i < 10; i++) {
  result.push(arr[i]);
}
ready
concat map
result = result.concat(_.map(arr, function(i) {
  return i;
}))
ready

Revisions

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