spread operator to push

JavaScript performance comparison

Revision 2 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var array1 = [];
  var array2 = [];
  var array3 = [];
  var array4 = [];
  var array5 = [];
  var array6 = [];
  
  for (var i = 0; i < 1000; i++) {
    array1.push('1' + i);
    array2.push('1' + i);
  }
  
  for (var i = 0; i < 10000; i++) {
    array3.push('1' + i);
    array4.push('1' + i);
  }
  
  for (var i = 0; i < 100000; i++) {
    array5.push('1' + i);
    array6.push('1' + i);
  }
  
  

};
</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
1k: spread operator
array1.push(...array2);
pending…
1k: concat
var result = array1.concat(array2);
pending…
10k spread operator
array3.push(...array4);
pending…
10k concat
var result = array3.concat(array4);
pending…
100k spread operator
array5.push(...array6);
pending…
100k concat
var result = array5.concat(array6);
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