Javascript array concat vs push - single values at a time (v63)

Revision 63 of this benchmark created on


Description

1) var initialArr=[1,2,3];

var iterations=1000;

for(var i=4;i<iterations;i++){ initialArr = initialArr.concat(i); }

2) var arr1=[1,2,3]; var iterations=10000; for(var i=4;i<iterations;i++){ initialArr.push(i); }

Setup

var initialArr = [1, 2, 3]
    var iterations = 1000;

Test runner

Ready to run.

Testing in
TestOps/sec
concat
for (var i = 4; i < iterations; i++) {
  initialArr = initialArr.concat(i);
}
ready
push
for (var i = 4; i < iterations; i++) {
  initialArr.push(i);
}
ready

Revisions

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