Concat vs Splice (v4)

Revision 4 of this benchmark created on


Description

Compare repeated concat to splice

Test runner

Ready to run.

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

Revisions

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