Javascript array concat vs push

JavaScript performance comparison

Revision 174 of this test case created by Roman Hotsiy

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var originalArr1 = arr1.slice();
  var originalArr2 = arr2.slice();

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
push.apply
var arr1 = originalArr1.slice();
var arr2 = originalArr2.slice();
Array.prototype.push.apply(arr1, arr2);
pending…
concat
var arr1 = originalArr1.slice();
var arr2 = originalArr2.slice();
arr1 = arr1.concat(arr2);
pending…

Compare results of other browsers

Revisions

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

0 Comments