concat vs spread 20190423

JavaScript performance comparison

Test case created by towozy

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var shortArr = createArr(100);
  var longArr = createArr(1000)
  var str = "1234567890qwertyuiopasdfghjklzxcvbnm1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./"
  
  function createArr(len) {
      var arr = [];
      for (var i=0; i < len; i++) {
        arr.push(str);
      }
      return arr;
  }

};
</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
spread
[...longArr, ...shortArr];
pending…
concat
longArr.concat(shortArr);
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