Concat vs Splice (v5)

Revision 5 of this benchmark created on


Description

Compare repeated concat to splice

Setup

var a = [1,2,3,4,5,6,7,8,9,9,9,7,0,0,6,5];

Test runner

Ready to run.

Testing in
TestOps/sec
Concat
var x = [];
for(var i = 0; i < 1000; i++) {
  x = x.concat(a);
}
ready
Splice
var y = [];
for(var i = 0; i < 1000; i++) {
   Array.prototype.splice.apply(y, [-1, 0].concat(a));
}
ready

Revisions

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