Mass push

Benchmark created on


Preparation HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.3.1/lodash.min.js"></script>

Setup

var a = _.range(1e4)
    var b = _.range(1e3)

Test runner

Ready to run.

Testing in
TestOps/sec
push.apply
a.push.apply(a, b)
ready
concat
a = a.concat(b)
ready
for..assign
for (var i = a.length, j = 0, n = b.length; j < n; i++, j++) {
  a[i] = b[j]
}
ready
for..push
for (var i = 0, n = b.length; i < n; i++) {
  a.push(b[i])
}
ready
forEach..push
b.forEach(function(x) { a.push(x) })
ready
_.each..push
_.each(b, function(x) { a.push(x) })
ready
_.each..assign
var i = a.length
_.each(b, function(x) { a[i++] = x })
ready

Revisions

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